ColaOrderedSet<T>
Namespace: SnowBank.Collections.CacheOblivious · class
Implements: IEnumerable<T>, IEnumerable, IDisposable
Represent an ordered set of elements, stored in a Cache Oblivious Lookup Array
Remarks
Inserts are in O(LogN) amortized. Lookups are in O(Log(N))
Constructors
ColaOrderedSet<T>
ColaOrderedSet<T>(ArrayPool<T> pool = null)
Constructs a ColaOrderedSet
pool— Pool used to allocate the internal levels (optional)
ColaOrderedSet<T>(int capacity, ArrayPool<T> pool = null)
Constructs a ColaOrderedSet with the given initial capacity
capacity— Initial capacitypool— Pool used to allocate the internal levels (optional)
ColaOrderedSet<T>(IComparer<T> comparer, ArrayPool<T> pool = null)
Constructs a ColaOrderedSet with the given comparer
comparer— Value comparerpool— Pool used to allocate the internal levels (optional)
ColaOrderedSet<T>(int capacity, IComparer<T> comparer, ArrayPool<T> pool = null)
Constructs a ColaOrderedSet with the given initial capacity and comparer
capacity— Initial capacitycomparer— Value comparerpool— Pool used to allocate the internal levels (optional)
Properties
Capacity
int Capacity { get; }
Current capacity of the set
Comparer
IComparer<T> Comparer { get; }
Instance used to compare values in the set
Count
int Count { get; }
Gets the number of elements in the immutable sorted set.
Item
T Item { get; }
Methods
Add
bool Add(T value)
Adds the specified value to this ordered set.
value— The value to add.
If the value already exists in the set, it will not be overwritten
Clear
void Clear()
Removes all the elements in the set
Contains
bool Contains(T value)
Determines whether this immutable sorted set contains the specified value.
value— The value to check for.
Returns: true if the set contains the specified value; otherwise, false.
CopyTo
void CopyTo(Span<T> destination)
Copy the ordered elements of the set to an array
destination— The one-dimensional array that is the destination of the elements copied from collection. The array must have zero-based indexing.
void CopyTo(T[] destination)
Copy the ordered elements of the set to an array
destination— The one-dimensional array that is the destination of the elements copied from collection. The array must have zero-based indexing.
Debug_Dump
void Debug_Dump(TextWriter output)
Writes the contents of this set into a log, for debugging purpose [DEBUG ONLY]
Dispose
void Dispose()
GetEnumerator
Enumerator<T> GetEnumerator()
IndexOf
int IndexOf(T value)
Find an element
Returns: The zero-based index of the first occurrence of value within the entire list, if found; otherwise, –1.
Remove
bool Remove(T value)
Removes the specified value from the set.
value— The value to remove.
Returns: true if the value was found and removed; otherwise, false
RemoveAt
T RemoveAt(int arrayIndex)
Removes the value at the specified location
arrayIndex— Index (0-based) of the value to remove, using the natural order of the set
Returns: Value that was removed
Set
bool Set(T value)
Adds or overwrite the specified value to this ordered set.
value— The value to add.
If the value already exists in the set, it will be overwritten by
TryCopyTo
bool TryCopyTo(Span<T> destination)
Copy the ordered elements of the set to an array
destination— The one-dimensional array that is the destination of the elements copied from collection. The array must have zero-based indexing.
Returns: true if the buffer was large enough; otherwise, false.
TryGetValue
bool TryGetValue(T value, out T actualValue)
Searches the set for a given value and returns the equal value it finds, if any.
value— The value to search for.actualValue— The value from the set that the search found, or the original value if the search yielded no match.
Returns: A value indicating whether the search was successful.
TryRemove
bool TryRemove(T value, out T actualValue)
Removes the specified value from the set, if it exists.
value— The value to remove.actualValue— Receives the actual value that was removed.
Returns: true if the value was found and removed; otherwise, false