fixes #1496
This commit is contained in:
parent
faf8d07056
commit
280fa9624c
4 changed files with 84 additions and 41 deletions
|
|
@ -8,6 +8,8 @@
|
|||
#
|
||||
|
||||
## Implementation of a queue. The underlying implementation uses a ``seq``.
|
||||
## Note: For inter thread communication use
|
||||
## a `TChannel <channels.html>``_ instead.
|
||||
|
||||
import math
|
||||
|
||||
|
|
|
|||
37
lib/pure/collections/rtarrays.nim
Normal file
37
lib/pure/collections/rtarrays.nim
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2014 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
|
||||
## Module that implements a fixed length array whose size
|
||||
## is determined at runtime. Note: This is not ready for other people to use!
|
||||
|
||||
const
|
||||
ArrayPartSize = 10
|
||||
|
||||
type
|
||||
RtArray*[T] = object ##
|
||||
L: Natural
|
||||
spart: seq[T]
|
||||
apart: array [ArrayPartSize, T]
|
||||
UncheckedArray* {.unchecked.}[T] = array[0..100_000_000, T]
|
||||
|
||||
|
||||
template usesSeqPart(x): expr = x.L > ArrayPartSize
|
||||
|
||||
proc initRtArray*[T](len: Natural): RtArray[T] =
|
||||
result.L = len
|
||||
if usesSeqPart(result):
|
||||
newSeq(result.spart, len)
|
||||
|
||||
proc getRawData*[T](x: var RtArray[T]): ptr UncheckedArray[T] =
|
||||
if usesSeqPart(x): cast[ptr UncheckedArray[T]](addr(x.spart[0]))
|
||||
else: cast[ptr UncheckedArray[T]](addr(x.apart[0]))
|
||||
|
||||
#proc len*[T](x: RtArray[T]): int = x.L
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ when useUnicode:
|
|||
|
||||
const
|
||||
InlineThreshold = 5 ## number of leaves; -1 to disable inlining
|
||||
MaxSubpatterns* = 10 ## defines the maximum number of subpatterns that
|
||||
MaxSubpatterns* = 20 ## defines the maximum number of subpatterns that
|
||||
## can be captured. More subpatterns cannot be captured!
|
||||
|
||||
type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue