Enhanced C#
Loyc library documentation
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public Member Functions | Protected Member Functions | List of all members
Loyc.Collections.Impl.BListLeaf< K, T > Class Template Reference

Internal implementation class. Leaf node of BList{T} and BDictionary{K,V}. More...


Source file:
Inheritance diagram for Loyc.Collections.Impl.BListLeaf< K, T >:
Loyc.Collections.Impl.AListLeaf< K, T > Loyc.Collections.Impl.AListLeafBase< K, T > Loyc.Collections.Impl.AListNode< K, T >

Remarks

Internal implementation class. Leaf node of BList{T} and BDictionary{K,V}.

Public Member Functions

 BListLeaf (ushort maxNodeSize)
 
 BListLeaf (BListLeaf< K, T > frozen)
 
override AListNode< K, T > DetachedClone ()
 Creates an unfrozen shallow duplicate copy of this node. The child nodes (if this is an inner node) are frozen so that they will require duplication if they are to be modified. The name "DetachedClone" is intended to emphasize that the AListNodeObserver (if any) is not notified, and the clone is effectively independent of the list that it came from. More...
 
override AListNode< K, T > CopySection (uint index, uint count, AListBase< K, T > list)
 Extracts and returns, as fast as possible, a subrange of the list that this node represents. More...
 
override bool RemoveAt (uint index, uint count, IAListTreeObserver< K, T >?tob)
 Removes an item at the specified index. More...
 
- Public Member Functions inherited from Loyc.Collections.Impl.AListLeaf< K, T >
override long CountSizeInBytes (int sizeOfT, int sizeOfK)
 Tallies the memory use of the current node and all child nodes, with the assumption that each object has a header size of two words (e.g. class Foo {} has a size of 16 bytes per Foo object in a 64-bit process), and arrays have a header size of three words. More...
 
 AListLeaf (ushort maxNodeSize)
 
 AListLeaf (AListLeaf< K, T > original)
 
override void SetAt (uint index, T item, IAListTreeObserver< K, T >?tob)
 Sets an item at the specified sub-index. More...
 
override T GetLastItem ()
 Gets the last item in the last leaf node (needed by B+ trees, but is also called by AListBase{K,T}.Last). More...
 
override void Freeze ()
 
void Sort (int start, int subcount, Comparison< T > comp)
 
sealed override int IndexOf (T item, int startIndex)
 
override uint GetImmutableCount (bool _)
 Diagnostic method. See AListBase{K,T}.GetImmutableCount(). More...
 
override IEnumerator< T > GetEnumerator ()
 
- Public Member Functions inherited from Loyc.Collections.Impl.AListNode< K, T >
virtual AListNode< K, T > Insert (uint index, T item, out AListNode< K, T >?splitRight, IAListTreeObserver< K, T >?tob)
 Inserts an item at the specified index. This method can only be called for ALists, since other tree types don't allow insertion at a specific index. More...
 
virtual AListNode< K, T > InsertRange (uint index, IListSource< T > source, ref int sourceIndex, out AListNode< K, T >?splitRight, IAListTreeObserver< K, T >?tob)
 Inserts a list of items at the specified index. This method may not insert all items at once, so there is a sourceIndex parameter which points to the next item to be inserted. When sourceIndex reaches source.Count, the insertion is complete. More...
 
virtual uint GetRealItemCount ()
 For sparse lists: counts the number of non-sparse items. More...
 

Protected Member Functions

 BListLeaf (ushort maxNodeSize, InternalList< T > list)
 
- Protected Member Functions inherited from Loyc.Collections.Impl.AListLeaf< K, T >
 AListLeaf (ushort maxNodeSize, InternalList< T > list)
 
void EnsureCapacity (int amountToInsert)
 
- Protected Member Functions inherited from Loyc.Collections.Impl.AListNode< K, T >
IAListTreeObserver< K, T > GetObserver (AListBase< K, T > tree)
 Allows derived classes of AListNode to access AListBase._observer. More...
 
bool HasListChanging (AListBase< K, T > tree)
 Allows derived classes of AListNode to fire the AListBase.ListChanging event. More...
 
void CallListChanging (AListBase< K, T > tree, ListChangeInfo< T > listChangeInfo)
 Allows derived classes of AListNode to fire the AListBase.ListChanging event properly. More...
 

Additional Inherited Members

- Public fields inherited from Loyc.Collections.Impl.AListLeaf< K, T >
const int DefaultMaxNodeSize = 64
 
override bool IsLeaf => true
 
sealed override int LocalCount => _list.Count
 
override uint TotalCount => (uint)_list.Count
 
sealed override bool IsFullLeaf => _list.Count >= _maxNodeSize
 
override bool IsUndersized => _list.Count * 3 <= _maxNodeSize
 
override int CapacityLeft => _maxNodeSize - LocalCount
 
override T this[uint index] => _list[(int)index]
 
- Properties inherited from Loyc.Collections.Impl.AListNode< K, T >
abstract bool IsLeaf [get]
 
abstract uint TotalCount [get]
 Gets the total number of (T) items in this node and all children More...
 
abstract int LocalCount [get]
 Gets the number of items (slots) used this node only. More...
 
abstract bool IsFullLeaf [get]
 Returns true if the node is full and is a leaf node. More...
 
abstract bool IsUndersized [get]
 Returns true if the node is undersized, meaning it would prefer to have more immediate children. More...
 
abstract T this[uint index] [get]
 Gets an item at the specified sub-index. More...
 
bool IsFrozen [get]
 Returns true if the node is explicitly marked read-only. Conceptually, the node can still be changed, but when any change needs to be made, a clone of the node is created and modified instead. More...
 
abstract int CapacityLeft [get]
 
- Static Public Member Functions inherited from Loyc.Collections.Impl.AListNode< K, T >
static bool AutoClone (ref AListNode< K, T > node, AListInnerBase< K, T >?parent, IAListTreeObserver< K, T >?tob)
 Checks whether 'node' is frozen and if so, replaces it with an unfrozen copy. More...
 
- Static Protected Member Functions inherited from Loyc.Collections.Impl.AListNode< K, T >
static void Verify (bool condition)
 Same as Assert(), except that the condition expression can have side-effects because it is evaluated even in Release builds. More...
 
- Protected fields inherited from Loyc.Collections.Impl.AListNode< K, T >
ushort _maxNodeSize
 Maximum number of slots in this node More...
 
volatile bool _isFrozen
 Whether the node is knowingly cloned an therefore frozen. More...
 
byte _childCount
 Number of children, if this is an inner node. More...
 

Member Function Documentation

override AListNode<K, T> Loyc.Collections.Impl.BListLeaf< K, T >.CopySection ( uint  index,
uint  count,
AListBase< K, T >  list 
)
inlinevirtual

Extracts and returns, as fast as possible, a subrange of the list that this node represents.

Parameters
indexIndex to start copying
countNumber of Ts to copy (must be greater than zero).
listList that is making the request. This parameter may be needed by organized trees that need to call list.GetKey().

This method may return a size-one inner node that the caller must replace with its child. It will fast-clone any nodes that can be copied in their entirety, including this node itself.

Implements Loyc.Collections.Impl.AListNode< K, T >.

override AListNode<K, T> Loyc.Collections.Impl.BListLeaf< K, T >.DetachedClone ( )
inlinevirtual

Creates an unfrozen shallow duplicate copy of this node. The child nodes (if this is an inner node) are frozen so that they will require duplication if they are to be modified. The name "DetachedClone" is intended to emphasize that the AListNodeObserver (if any) is not notified, and the clone is effectively independent of the list that it came from.

Implements Loyc.Collections.Impl.AListNode< K, T >.

override bool Loyc.Collections.Impl.BListLeaf< K, T >.RemoveAt ( uint  index,
uint  count,
IAListTreeObserver< K, T >?  tob 
)
inlinevirtual

Removes an item at the specified index.

Returns
Returns true if the node is undersized after the removal, or if this is an organized tree and the removal caused the aggregate key (highest key in a B+tree) to change.

When the node is undersized, but is not the root node, the parent will shift an item from a sibling, or discard the node and redistribute its children among existing nodes. If it is the root node, it is only discarded if it is an inner node with a single child (the child becomes the new root node), or it is a leaf node with no children.

Reimplemented from Loyc.Collections.Impl.AListLeaf< K, T >.