Bounds and queue size checking can now be disabled
This commit is contained in:
parent
eaaac53be0
commit
39a789b068
|
@ -107,6 +107,8 @@ queue.clearPop()
|
|||
capabilities
|
||||
- The objects in this module are **all** tracked references! (Unlike the `std/deques` module which implements them as value
|
||||
types and gives `var` variants of each procedure)
|
||||
- As with the data structure implemented in `std/deques`, all bounds checking is disabled when compiled with
|
||||
`--checks:off` or `-d:danger`, but queue size checking is not. To disable queue size checking, pass `-d:noQueueSizeCheck`
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ proc maxSize*[T](self: LinkedDeque[T]): int =
|
|||
proc getNode[T](self: LinkedDeque[T], i: int): DequeNode[T] {.raises: [IndexDefect, ValueError].} =
|
||||
## Low level method for indexing and getting
|
||||
## a node object back
|
||||
when defined(boundChecks):
|
||||
if self.high() == -1:
|
||||
raise newException(IndexDefect, "LinkedDeque is empty")
|
||||
elif i > self.high() or i < 0:
|
||||
|
@ -217,6 +218,7 @@ proc insert*[T](self: LinkedDeque[T], pos: int, val: T) {.raises: [IndexDefect,
|
|||
## to O(n) the closer the index gets to the middle of
|
||||
## the deque. This proc raises an IndexDefect if the
|
||||
## queue's max size is reached
|
||||
when not defined(noQueueSizeCheck):
|
||||
if self.maxSize > 0 and self.size == self.maxSize:
|
||||
raise newException(IndexDefect, &"LinkedDeque has reached its maximum size ({self.maxSize})")
|
||||
if pos == 0:
|
||||
|
|
Loading…
Reference in New Issue