Eamon CS  3.1.0
Eamon.ThirdParty.BTree< T > Class Template Reference

A sorted collection (set) data structure using b-trees. More...

Inheritance diagram for Eamon.ThirdParty.BTree< T >:
Eamon.ThirdParty.ISortedCollection< T >

Public Member Functions

 BTree ()
 Initializes a new BTree instance; used by the SharpSerializer. More...
 
 BTree (int nodeCapacity=128)
 Initializes a new BTree instance. More...
 
 BTree (IComparer< T > comparer, int nodeCapacity=128)
 Initializes a new BTree instance with the specified comparer. More...
 
At (int index)
 Gets the item at the specified index. O(log N) More...
 
bool Contains (T value)
 Gets a value indicating whether the specified value is in the collection. O(log N) More...
 
bool TryGetValue (T equalValue, out T actualValue)
 Searches the collection for a given value and returns the equal value it finds, if any. O(log N) More...
 
void Add (T value)
 Adds the specified value to the collection. O(log N) More...
 
void Clear ()
 Clears the collection of all elements. O(1) More...
 
bool Remove (T value)
 Removes the specified key value from the collection. O(log N) More...
 
void RemoveAt (int index)
 Removes the item at the specified index. O(log N) More...
 
IEnumerator< T > GetEnumerator ()
 Gets an enumerator for the collection. O(1), move next: O(1) More...
 
void CopyTo (T[] array, int arrayIndex)
 Copies the collection into the specified array. O(N) More...
 
int FirstIndexWhereGreaterThan (T value)
 Gets the index of the first item greater than the specified value. O(log N), move next: O(1) More...
 
int LastIndexWhereLessThan (T value)
 Gets the index of the last item less than the specified key. O(log N), move next: O(1) More...
 
IEnumerable< T > WhereGreaterOrEqual (T value)
 Get all items equal to or greater than the specified value, starting with the lowest index and moving forwards. O(log N), move next: O(1) More...
 
IEnumerable< T > WhereLessOrEqualBackwards (T value)
 Get all items less than or equal to the specified value, starting with the highest index and moving backwards. O(log N), move next: O(1) More...
 
IEnumerable< T > ForwardFromIndex (int index)
 Get all items starting at the index, and moving forward. O(log N), move next: O(1) More...
 
IEnumerable< T > BackwardFromIndex (int index)
 Get all items starting at the index, and moving backward. O(log N), move next: O(1) More...
 

Public Attributes

int Count => _root.TotalCount
 Gets the number of items in the collection. More...
 

Properties

IComparer< T > Comparer [get]
 Gets the comparer used to order items in the collection. More...
 
bool IsReadOnly [get, set]
 Gets or sets indication whether this collection is readonly or mutable. More...
 
bool AllowDuplicates [get, set]
 Gets or sets indication whether this collection allows duplicate values. More...
 
- Properties inherited from Eamon.ThirdParty.ISortedCollection< T >
IComparer< T > Comparer [get]
 Gets the comparer used to order items in the collection. More...
 
bool AllowDuplicates [get]
 Gets indication of whether the collection allows duplicate values. More...
 

Detailed Description

A sorted collection (set) data structure using b-trees.

Template Parameters
TThe type of items in the collection.

Constructor & Destructor Documentation

◆ BTree() [1/3]

Initializes a new BTree instance; used by the SharpSerializer.

◆ BTree() [2/3]

Eamon.ThirdParty.BTree< T >.BTree ( int  nodeCapacity = 128)

Initializes a new BTree instance.

Parameters
nodeCapacityThe node capacity.

◆ BTree() [3/3]

Eamon.ThirdParty.BTree< T >.BTree ( IComparer< T >  comparer,
int  nodeCapacity = 128 
)

Initializes a new BTree instance with the specified comparer.

Parameters
comparer
nodeCapacity

Member Function Documentation

◆ Add()

void Eamon.ThirdParty.BTree< T >.Add ( value)

Adds the specified value to the collection. O(log N)

Parameters
valueThe value to add.

◆ At()

T Eamon.ThirdParty.BTree< T >.At ( int  index)

Gets the item at the specified index. O(log N)

Parameters
indexThe index for the item to retrieve.
Returns
The value of the item at the specified index.

Implements Eamon.ThirdParty.ISortedCollection< T >.

◆ BackwardFromIndex()

IEnumerable<T> Eamon.ThirdParty.BTree< T >.BackwardFromIndex ( int  index)

Get all items starting at the index, and moving backward. O(log N), move next: O(1)

Implements Eamon.ThirdParty.ISortedCollection< T >.

◆ Clear()

void Eamon.ThirdParty.BTree< T >.Clear ( )

Clears the collection of all elements. O(1)

◆ Contains()

bool Eamon.ThirdParty.BTree< T >.Contains ( value)

Gets a value indicating whether the specified value is in the collection. O(log N)

Parameters
valueThe value.
Returns
True if the collection contains at item with the value; Otherwise, false.

◆ CopyTo()

void Eamon.ThirdParty.BTree< T >.CopyTo ( T[]  array,
int  arrayIndex 
)

Copies the collection into the specified array. O(N)

Parameters
arrayThe array into which to copy.
arrayIndexThe index at which to start copying.

◆ FirstIndexWhereGreaterThan()

int Eamon.ThirdParty.BTree< T >.FirstIndexWhereGreaterThan ( value)

Gets the index of the first item greater than the specified value. O(log N), move next: O(1)

Parameters
valueThe value for which to find the index.
Returns
The index of the first item greater than the specified value, or Count if no such item exists.

Implements Eamon.ThirdParty.ISortedCollection< T >.

◆ ForwardFromIndex()

IEnumerable<T> Eamon.ThirdParty.BTree< T >.ForwardFromIndex ( int  index)

Get all items starting at the index, and moving forward. O(log N), move next: O(1)

Implements Eamon.ThirdParty.ISortedCollection< T >.

◆ GetEnumerator()

IEnumerator<T> Eamon.ThirdParty.BTree< T >.GetEnumerator ( )

Gets an enumerator for the collection. O(1), move next: O(1)

Returns
An enumerator for the collection.

◆ LastIndexWhereLessThan()

int Eamon.ThirdParty.BTree< T >.LastIndexWhereLessThan ( value)

Gets the index of the last item less than the specified key. O(log N), move next: O(1)

Parameters
valueThe value for which to find the index.
Returns
The index of the last item less than the specified value, or -1 if no such item exists.

Implements Eamon.ThirdParty.ISortedCollection< T >.

◆ Remove()

bool Eamon.ThirdParty.BTree< T >.Remove ( value)

Removes the specified key value from the collection. O(log N)

Parameters
valueThe key value to remove.
Returns
True if the value was added; otherwise, false.

◆ RemoveAt()

void Eamon.ThirdParty.BTree< T >.RemoveAt ( int  index)

Removes the item at the specified index. O(log N)

Parameters
indexThe index from which to remove.

Implements Eamon.ThirdParty.ISortedCollection< T >.

◆ TryGetValue()

bool Eamon.ThirdParty.BTree< T >.TryGetValue ( equalValue,
out T  actualValue 
)

Searches the collection for a given value and returns the equal value it finds, if any. O(log N)

Parameters
equalValueThe value of the node to search for.
actualValueThe value from the collection that the search found, or the default value of T when the search yielded no match.
Returns
A value indicating whether the search was successful.

Implements Eamon.ThirdParty.ISortedCollection< T >.

◆ WhereGreaterOrEqual()

IEnumerable<T> Eamon.ThirdParty.BTree< T >.WhereGreaterOrEqual ( value)

Get all items equal to or greater than the specified value, starting with the lowest index and moving forwards. O(log N), move next: O(1)

Parameters
valueThe value.
Returns
All items having values equal to or greater than the specified value.

Implements Eamon.ThirdParty.ISortedCollection< T >.

◆ WhereLessOrEqualBackwards()

IEnumerable<T> Eamon.ThirdParty.BTree< T >.WhereLessOrEqualBackwards ( value)

Get all items less than or equal to the specified value, starting with the highest index and moving backwards. O(log N), move next: O(1)

Parameters
valueThe key value.
Returns
All items having values equal to or greater than the specified value.

Implements Eamon.ThirdParty.ISortedCollection< T >.

Member Data Documentation

◆ Count

int Eamon.ThirdParty.BTree< T >.Count => _root.TotalCount

Gets the number of items in the collection.

Property Documentation

◆ AllowDuplicates

bool Eamon.ThirdParty.BTree< T >.AllowDuplicates
getset

Gets or sets indication whether this collection allows duplicate values.

◆ Comparer

IComparer<T> Eamon.ThirdParty.BTree< T >.Comparer
get

Gets the comparer used to order items in the collection.

◆ IsReadOnly

bool Eamon.ThirdParty.BTree< T >.IsReadOnly
getset

Gets or sets indication whether this collection is readonly or mutable.


The documentation for this class was generated from the following file: