我有一个包含很多多边形的地图,其中一个有一个点,如下所示:

多边形边缘的x和y坐标保存在这样的数据库中(例如):
Polygon(Point(11824, 10756), Point(11822, 10618), Point(11912, 10517), Point(12060, 10529), Point(12158, 10604), Point(12133, 10713), Point(12027, 10812), Point(11902, 10902)),
Polygon(Point(11077, 13610), Point(10949, 13642), Point(10828, 13584), Point(10772, 13480), Point(10756, 13353), Point(10849, 13256), Point(10976, 13224), Point(11103, 13294), Point(11171, 13414), Point(11135, 13558)),
Polygon(Point(11051.801757813, 11373.985351563), Point(11165.717773438, 11275.469726563), Point(11281.733398438, 11255.646484375), Point(11381.07421875, 11333.15625), Point(11440.202148438, 11467.706054688), Point(11404.73046875, 11584.534179688), Point(11301.662109375, 11643.852539063), Point(11169.486328125, 11644.079101563), Point(11067.555664063, 11579.676757813), Point(11018.21484375, 11454.750976563)),
Polygon(Point(12145, 13013), Point(12069.065429688, 13014.67578125), Point(12012.672851563, 12953.833984375), Point(11973.942382813, 12910.14453125), Point(11958.610351563, 12853.736328125), Point(11988.58203125, 12780.668945313), Point(12046.806640625, 12735.046875), Point(12117.080078125, 12729.838867188), Point(12185.567382813, 12743.389648438), Point(12225.575195313, 12803.530273438), Point(12255.934570313, 12859.2109375), …Run Code Online (Sandbox Code Playgroud) 在控制台应用程序中。我需要从主线程加载一些长时间运行的代码(网络内容、REST 调用)。我想将它传递给后台线程并且不阻塞调用线程。我将调用该方法中的事件来处理其结果。
这样做有什么区别吗?
public async Task MainThreadAsync() {
_ = Task.Run(async () => await DoSomethingAsync());
// Continue with other stuff and don't care about DoSomethingAsync()
}
private async Task DoSomethingAsync() {
// Doing long running stuff
}
Run Code Online (Sandbox Code Playgroud)
或这样做?
public async Task MainThreadAsync() {
DoSomethingAsync();
// Continue with other stuff and don't care about DoSomethingAsync()
}
private async void DoSomethingAsync() {
// Doing long running stuff
}
Run Code Online (Sandbox Code Playgroud)
VB.Net:
Public Async Function MainThreadAsync() As Task
Task.Run(Async Function() As Task
Await DoSomethingAsync()
End …Run Code Online (Sandbox Code Playgroud) 当我用lua检查两个条件时,哪个方式的运行时间更快?
if bool and somefuntion() then
do stuff
end
Run Code Online (Sandbox Code Playgroud)
要么
if bool then
if somefuntion() then
do stuff
end
end
Run Code Online (Sandbox Code Playgroud)
?
我设置了一些这样的变量:
local var1Age = 10
local var2Age = 20
local var3Age = 30
Run Code Online (Sandbox Code Playgroud)
现在我想用这样的循环迭代它们:
for i=1, 3 do
if var..i..Age >= 21 then
print("yep")
end
end
Run Code Online (Sandbox Code Playgroud)
我无法更改变量,也无法创建表格.这个变量有可能吗?
编辑: 我可以这样做:
if var1Age >= 21 then
print("yep")
end
if var2Age >= 21 then
print("yep")
end
if var3Age >= 21 then
print("yep")
end
Run Code Online (Sandbox Code Playgroud)
但我有~50个这样的变量.这就是我搜索循环方式的原因.
Edit2: vars是由我无法改变的类设置的,因此我无法改变vars的设置方式.例如,我不能像这样设置变量:
local varAge = {}
varAge[1] = 10
varAge[2] = 20
varAge[3] = 30
Run Code Online (Sandbox Code Playgroud)
Edit3: 该类将vars保存在如下表格中:http://ideone.com/iO4I8N
我想设置表成员的索引,但仍然命名它们.那可能吗?
local table = {
["cat"] = {
["fish"] = { stuff = "bla1", stuff2 = "bla" },
["mouse"] = { stuff = "bla2", stuff2 = "bla" },
["bird"] = { stuff = "bla3", stuff2 = "bla" },
},
["dog"] = {
["fish"] = { stuff = "bla1", stuff2 = "bla" },
["mouse"] = { stuff = "bla2", stuff2 = "bla" },
["bird"] = { stuff = "bla3", stuff2 = "bla" },
},
}
Run Code Online (Sandbox Code Playgroud)
table["cat"][1]是fish,但我想要的table["cat"][0]是 …
我正在开发一个“简单”基数转换器,用于将基数为 10 的 ULong 转换为任何基数的字符串。这里我使用64个字符。用例是缩短存储为字符串的 ULong。
Public Class BaseConverter
'base64, but any length would work
Private Shared ReadOnly Characters() As Char = {"0"c, "1"c, "2"c, "3"c, "4"c, "5"c, "6"c, "7"c, "8"c, "9"c,
"a"c, "b"c, "c"c, "d"c, "e"c, "f"c, "g"c, "h"c, "i"c, "j"c, "k"c, "l"c, "m"c, "n"c, "o"c, "p"c, "q"c, "r"c, "s"c, "t"c, "u"c, "v"c, "w"c, "x"c, "y"c, "z"c,
"A"c, "B"c, "C"c, "D"c, "E"c, "F"c, "G"c, "H"c, "I"c, "J"c, "K"c, "L"c, "M"c, "N"c, "O"c, "P"c, "Q"c, "R"c, "S"c, "T"c, "U"c, "V"c, …Run Code Online (Sandbox Code Playgroud) lua ×3
.net ×2
vb.net ×2
.net-core ×1
algorithm ×1
arrays ×1
async-await ×1
asynchronous ×1
c# ×1
for-loop ×1
geometry ×1
if-statement ×1
lua-table ×1
math ×1
performance ×1
point ×1
polygon ×1
radix ×1
runtime ×1
variables ×1