| File | Date | Author | Commit |
|---|---|---|---|
| docs | 2025-09-07 |
|
[76b59c] UniqueValue a.k.a. UniqueValues |
| .hgignore | 2025-08-29 |
|
[8fae27] Initial code - compiles but untested |
| .hgtags | 2025-09-07 |
|
[057867] Moved tag V0-Latest to changeset 76b59c387f73 (... |
| README.md | 2025-09-01 |
|
[c7085d] Patched README install instructions |
| docs.html | 2025-08-29 |
|
[3332b6] More code added and some sucesssful tests |
| unique_values.nim | 2025-09-07 |
|
[76b59c] UniqueValue a.k.a. UniqueValues |
| unique_values.nimble | 2025-09-07 |
|
[76b59c] UniqueValue a.k.a. UniqueValues |
These functions will store values in an array, ensuring no value
stored is ever repeated.
The fact that these are stored in a flat array rather than some
type of B-Tree structure means it can become a bit inefficient
storing a very large collection of values, but will be adequate
for smaller collections of value.
The collection may be (at the user's discretion) sorted or unsorted.
For larger collections having the collection sorted might make
reading from the collection faster, although it probably Wii make
little difference to the performance when writing to the collection.
Generally, all functions that update the collection (e.g. add or
sort) will never return an error. They will either work or they
will simply do nothing. The only singular exception to this is if
you have a collection of floats, or a collection of objects that
contain at least one float, then calling the add() function where
the float value is NaN will cause a ValueError to be raised. This is
because of quirks in the way IEEE 754 requires that a NaN value is
never equal to another NaN value, with means that NaN values would
poison the collection of UniqueValue items.
All functions that update the collection will update the collection
in-situ, but they will also return the updated collection as
an optional output. Returning the updated collection allows for
functions to be cascaded so:
var collection = UniqueValues.new(int)
collection.add(20)
collection.add(30)
collection.sort
collection.add(5)
is exactly equivalent to:
var collection = UniqueValues.new(int).add(20).add(30).sort.add(5)
nimble install "http://hg.code.sf.net/p/nim-unique-values/code"