Its not that simple. Capacity != Count in underlying table. Still, IMO this
should be in tables.nim. Its not ideal but better than nothing.
proc raiseIndexError(ndx, max : int) =
raise newException(IndexError, "index " & $ndx & " not in 0.." &
$(max-1))
proc keyAt*[A,B](t: OrderedTable[A, B], at: int) : A =
if at<0 or at>=t.counter:
raiseIndexError(at,t.counter)
var ndx = 0
forAllOrderedPairs:
if at == ndx:
result = t.data[h].key
break
inc(ndx)
proc valueAt*[A,B](t: OrderedTable[A, B], at : int) : B =
if at<0 or at>=t.counter:
raiseIndexError(at,t.counter)
if at<0 or at>=t.counter:
raise newException(IndexError, $at)
var ndx = 0
forAllOrderedPairs:
if at == ndx:
result = t.data[h].val
break
inc(ndx)
Run
- Can I quick get table last key value use like at(idx) function... Angluca
- Can I quick get table last key value use like at(idx) fun... doofenstein
- Can I quick get table last key value use like at(idx)... Angluca
- Can I quick get table last key value use like at(... sky_khan
- Can I quick get table last key value use like... xigoi
- Can I quick get table last key value use... Araq
- Can I quick get table last key value... Angluca
- Can I quick get table last key v... sky_khan
- Can I quick get table last key v... Angluca
- Can I quick get table last key v... Zoom
- Can I quick get table last key v... Angluca
- Can I quick get table last key value use like at(idx) fun... planetis
