DeveelDB
20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
|
An implementation of an index of values that are stored across an array of blocks. More...
Classes | |
class | Enumerator |
Public Member Functions | |
void | Insert (int index, T value) |
void | Add (T value) |
T | RemoveAt (int index) |
bool | Contains (T value) |
void | InsertSort (T value) |
bool | UniqueInsertSort (T value) |
bool | RemoveSort (T value) |
bool | Contains (object key, IIndexComparer< T > comparer) |
void | InsertSort (object key, T value, IIndexComparer< T > comparer) |
T | RemoveSort (object key, T value, IIndexComparer< T > comparer) |
int | SearchLast (object key, IIndexComparer< T > comparer) |
int | SearchFirst (object key, IIndexComparer< T > comparer) |
IIndexEnumerator< T > | GetEnumerator () |
IIndexEnumerator< T > | GetEnumerator (int startOffset, int endOffset) |
Protected Member Functions | |
BlockIndexBase () | |
BlockIndexBase (IEnumerable< IIndexBlock< T >> blocks) | |
BlockIndexBase (IEnumerable< T > values) | |
BlockIndexBase (IIndex< T > index) | |
abstract IIndexBlock< T > | NewBlock () |
Creates a new IIndexBlock<T> for the given implementation. More... | |
virtual void | OnDeleteBlock (IIndexBlock< T > block) |
Called when the class decides the given IIndexBlock<T> is no longer needed. More... | |
Package Functions | |
void | CopyToArray (T[] array, int offset, int length) |
Copies the data from each block into the given int[] array. More... | |
Properties | |
List< IIndexBlock< T > > | Blocks [get, private set] |
bool | IsReadOnly [get, set] |
int | Count [get, private set] |
T | this[int index] [get] |
Private Member Functions | |
IIndexBlock< T > | InsertBlock (int index, IIndexBlock< T > block) |
Inserts a block at the given position in the index. More... | |
void | RemoveBlock (int index) |
Removes a block from the given position in the index. More... | |
void | InsertIntoBlock (T value, int blockIndex, IIndexBlock< T > block, int position) |
Inserts a value in the given block position in the list. More... | |
T | RemoveFromBlock (int blockIndex, IIndexBlock< T > block, int position) |
Removes the value from the given position in the specified block. More... | |
int | FindBlockContaining (object key, IIndexComparer< T > comparer) |
Uses a binary search algorithm to quickly determine the index of the IIndexBlock<T> within 'blocks' of the block that contains the given key value using the IIndexComparer<T> as a lookup comparator. More... | |
int | FindLastBlock (object key, IIndexComparer< T > comparer) |
Uses a binary search algorithm to quickly determine the index of the IIndexBlock<T> within 'blocks' of the block that contains the given key value using the IIndexComparer<T> as a lookup comparator. More... | |
int | FindFirstBlock (object key, IIndexComparer< T > c) |
Uses a binary search algorithm to quickly determine the index of the IIndexBlock<T> within 'blocks' of the block that contains the given key value using the IIndexComparer<T> as a lookup comparator. More... | |
int | FindLastBlock (T val) |
Uses a binary search algorithm to quickly determine the index of the IIndexBlock<T> within 'blocks' of the block that contains the given value. More... | |
void | CheckImmutable () |
Checks if the current index is mutable. More... | |
IEnumerator< T > IEnumerable< T >. | GetEnumerator () |
IEnumerator IEnumerable. | GetEnumerator () |
Static Private Member Functions | |
static bool | IsSmallerOrEqual (T x, T y) |
static bool | IsGreaterOrEqual (T x, T y) |
static bool | IsGreater (T x, T y) |
static bool | IsSmaller (T x, T y) |
An implementation of an index of values that are stored across an array of blocks.
This allows for quicker insertion and deletion of values, including other memory saving benefits.
The class works as follows:
The benefits of this system are that inserts and deletes are fast even for very large lists. There are no megabyte sized arraycopies. Also, the object could be extended to a version that pages un-used blocks to disk thus saving precious system memory.
Note: The following methods are not optimal: Item(int), Insert(int, T), RemoveAt(int).
Specifically, they slow as the specified index nears the end of large lists.
This type of structure is very fast for large sorted lists where values can be inserted at any position within the list. Care needs to be taken for lists where values are inserted and removed constantly, because fragmentation of the list blocks can occur. For example, adding 60,000 random entries followed by removing 50,000 random entries will result in many only partially filled blocks. Since each block takes a constant amount of memory, this may not be acceptable.
T | : | IComparable<T> | |
T | : | IEquatable<T> |
Definition at line 63 of file BlockIndexBase_T.cs.
|
inlineprotected |
Definition at line 64 of file BlockIndexBase_T.cs.
|
inlineprotected |
Definition at line 70 of file BlockIndexBase_T.cs.
|
inlineprotected |
Definition at line 78 of file BlockIndexBase_T.cs.
|
inlineprotected |
Definition at line 85 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 547 of file BlockIndexBase_T.cs.
|
inlineprivate |
Checks if the current index is mutable.
This is called before any mutable operations on the index: if the index is mutable and empty then an empty block is added to the index.
InvalidOperationException | Thrown if the index is read-only. |
Definition at line 499 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 572 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 684 of file BlockIndexBase_T.cs.
|
inlinepackage |
Copies the data from each block into the given int[] array.
array | |
offset | |
length |
The int[] array must be big enough to fit all the data in this list.
Definition at line 520 of file BlockIndexBase_T.cs.
|
inlineprivate |
Uses a binary search algorithm to quickly determine the index of the IIndexBlock<T> within 'blocks' of the block that contains the given key value using the IIndexComparer<T> as a lookup comparator.
key | |
comparer |
Definition at line 290 of file BlockIndexBase_T.cs.
|
inlineprivate |
Uses a binary search algorithm to quickly determine the index of the IIndexBlock<T> within 'blocks' of the block that contains the given key value using the IIndexComparer<T> as a lookup comparator.
key | |
c |
Definition at line 379 of file BlockIndexBase_T.cs.
|
inlineprivate |
Uses a binary search algorithm to quickly determine the index of the IIndexBlock<T> within 'blocks' of the block that contains the given key value using the IIndexComparer<T> as a lookup comparator.
key | |
comparer |
Definition at line 327 of file BlockIndexBase_T.cs.
|
inlineprivate |
Uses a binary search algorithm to quickly determine the index of the IIndexBlock<T> within 'blocks' of the block that contains the given value.
val |
Definition at line 444 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 808 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 812 of file BlockIndexBase_T.cs.
|
inlineprivate |
Definition at line 816 of file BlockIndexBase_T.cs.
|
inlineprivate |
Definition at line 820 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 529 of file BlockIndexBase_T.cs.
|
inlineprivate |
Inserts a block at the given position in the index.
index | |
block |
Definition at line 165 of file BlockIndexBase_T.cs.
|
inlineprivate |
Inserts a value in the given block position in the list.
value | |
blockIndex | |
block | |
position |
Definition at line 223 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 586 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 698 of file BlockIndexBase_T.cs.
|
inlinestaticprivate |
Definition at line 429 of file BlockIndexBase_T.cs.
|
inlinestaticprivate |
Definition at line 425 of file BlockIndexBase_T.cs.
|
inlinestaticprivate |
Definition at line 433 of file BlockIndexBase_T.cs.
|
inlinestaticprivate |
Definition at line 421 of file BlockIndexBase_T.cs.
|
protectedpure virtual |
Creates a new IIndexBlock<T> for the given implementation.
Implemented in Deveel.Data.Index.BlockIndex< T >.
|
inlineprotectedvirtual |
Called when the class decides the given IIndexBlock<T> is no longer needed.
block |
Provided as an event for derived classes to intercept.
Definition at line 155 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 555 of file BlockIndexBase_T.cs.
|
inlineprivate |
Removes a block from the given position in the index.
index |
Definition at line 193 of file BlockIndexBase_T.cs.
|
inlineprivate |
Removes the value from the given position in the specified block.
blockIndex | |
block | |
position |
It returns the value that used to be at that position.
Definition at line 270 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 650 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 729 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 783 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 758 of file BlockIndexBase_T.cs.
|
inline |
Definition at line 617 of file BlockIndexBase_T.cs.
|
getprivate setprotected |
Definition at line 118 of file BlockIndexBase_T.cs.
|
getprivate set |
Definition at line 122 of file BlockIndexBase_T.cs.
|
getset |
Definition at line 120 of file BlockIndexBase_T.cs.
|
get |
Definition at line 124 of file BlockIndexBase_T.cs.