Merge branch 'mget' of https://github.com/def-/Nim into def--mget

Conflicts:
	lib/pure/collections/critbits.nim
	lib/pure/collections/tables.nim
	lib/pure/xmltree.nim
	lib/system/sets.nim
	tests/collections/ttables.nim
	tests/collections/ttablesref.nim
This commit is contained in:
Araq 2015-10-13 00:22:27 +02:00
commit d8b0edc323
12 changed files with 279 additions and 66 deletions

View file

@ -154,7 +154,7 @@ proc rawGetKnownHC[A](s: HashSet[A], key: A, hc: Hash): int {.inline.} =
proc rawGet[A](s: HashSet[A], key: A, hc: var Hash): int {.inline.} =
rawGetImpl()
proc mget*[A](s: var HashSet[A], key: A): var A =
proc `[]`*[A](s: var HashSet[A], key: A): var A =
## returns the element that is actually stored in 's' which has the same
## value as 'key' or raises the ``EInvalidKey`` exception. This is useful
## when one overloaded 'hash' and '==' but still needs reference semantics
@ -165,6 +165,13 @@ proc mget*[A](s: var HashSet[A], key: A): var A =
if index >= 0: result = s.data[index].key
else: raise newException(KeyError, "key not found: " & $key)
proc mget*[A](s: var HashSet[A], key: A): var A {.deprecated.} =
## returns the element that is actually stored in 's' which has the same
## value as 'key' or raises the ``EInvalidKey`` exception. This is useful
## when one overloaded 'hash' and '==' but still needs reference semantics
## for sharing. Use ```[]``` instead.
s[key]
proc contains*[A](s: HashSet[A], key: A): bool =
## Returns true iff `key` is in `s`.
##