Merge branch 'devel' into sorted_deduplicate
This commit is contained in:
commit
a1bf9fd2b6
494 changed files with 2495 additions and 2643 deletions
|
|
@ -140,11 +140,26 @@ proc contains*[T](L: SomeLinkedCollection[T], value: T): bool {.inline.} =
|
|||
## exist, true otherwise.
|
||||
result = find(L, value) != nil
|
||||
|
||||
proc append*[T](L: var SinglyLinkedList[T],
|
||||
n: SinglyLinkedNode[T]) {.inline.} =
|
||||
## appends a node `n` to `L`. Efficiency: O(1).
|
||||
n.next = nil
|
||||
if L.tail != nil:
|
||||
assert(L.tail.next == nil)
|
||||
L.tail.next = n
|
||||
L.tail = n
|
||||
if L.head == nil: L.head = n
|
||||
|
||||
proc append*[T](L: var SinglyLinkedList[T], value: T) {.inline.} =
|
||||
## appends a value to `L`. Efficiency: O(1).
|
||||
append(L, newSinglyLinkedNode(value))
|
||||
|
||||
proc prepend*[T](L: var SinglyLinkedList[T],
|
||||
n: SinglyLinkedNode[T]) {.inline.} =
|
||||
## prepends a node to `L`. Efficiency: O(1).
|
||||
n.next = L.head
|
||||
L.head = n
|
||||
if L.tail == nil: L.tail = n
|
||||
|
||||
proc prepend*[T](L: var SinglyLinkedList[T], value: T) {.inline.} =
|
||||
## prepends a node to `L`. Efficiency: O(1).
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
type
|
||||
UncheckedCharArray = UncheckedArray[char]
|
||||
|
||||
import system/helpers2
|
||||
|
||||
type
|
||||
Buffer = ptr object
|
||||
refcount: int
|
||||
|
|
@ -49,11 +51,11 @@ proc len*(s: SharedString): int = s.len
|
|||
|
||||
proc `[]`*(s: SharedString; i: Natural): char =
|
||||
if i < s.len: result = s.buffer.data[i+s.first]
|
||||
else: raise newException(IndexError, "index out of bounds")
|
||||
else: raise newException(IndexError, formatErrorIndexBound(i, s.len-1))
|
||||
|
||||
proc `[]=`*(s: var SharedString; i: Natural; value: char) =
|
||||
if i < s.len: s.buffer.data[i+s.first] = value
|
||||
else: raise newException(IndexError, "index out of bounds")
|
||||
else: raise newException(IndexError, formatErrorIndexBound(i, s.len-1))
|
||||
|
||||
proc `[]`*(s: SharedString; ab: HSlice[int, int]): SharedString =
|
||||
#incRef(src.buffer)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue