Enhanced C#
Language of your choice: library documentation
|
The tail of a VList contains only one or two items. To improve efficiency slightly, these two-item lists are represented by a VListBlockOfTwo, which is more compact than VListBlockArray. More...
The tail of a VList contains only one or two items. To improve efficiency slightly, these two-item lists are represented by a VListBlockOfTwo, which is more compact than VListBlockArray.
TODO: create a more efficient version using a "fixed T _array2[2]" in an unsafe code block (assuming it is generics-compatible).
Properties | |
override int | PriorCount [get] |
override FVList< T > | Prior [get] |
override int | Capacity [get] |
override T | this[int localIndex] [get, set] |
Properties inherited from Loyc.Collections.VListBlock< T > | |
bool | IsMutable [get] |
Returns true if part or all of the block is mutable. More... | |
abstract int | PriorCount [get] |
Returns the number of immutable items in all previous blocks. More... | |
abstract FVList< T > | Prior [get] |
Returns a FVList representing the tail of the chain of VListBlocks. More... | |
VListBlock< T > | PriorBlock [get] |
bool | PriorIsOwned [get] |
Returns true if this block has exclusive ownership of mutable items in the prior block. Returns false if the prior block is entirely immutable, if we don't have ownership, or if there is no prior block. More... | |
int | ImmCount [get] |
Gets the number of immutable elements in-use in our local array. More... | |
int | TotalCount [get] |
Returns the number of immutable elements in-use in the entire chain More... | |
abstract int | Capacity [get] |
Returns the maximum number of elements in this block More... | |
abstract T | this[int localIndex] [get, set] |
Gets/sets the specified value at the specified index of this block's array, or, if localIndex is negative, searches recursively in previous blocks for the desired index. More... | |
int | ChainLength [get] |
Public Member Functions | |
VListBlockOfTwo () | |
Initializes a mutable block with no items. More... | |
VListBlockOfTwo (T firstItem, bool mutable) | |
VListBlockOfTwo (T firstItem, T secondItem, bool mutable) | |
Initializes a block with two items. More... | |
override T | FGet (int index, int localCount) |
Gets an item at distance 'index' from the front (beginning of an FVList) More... | |
override bool | FGet (int index, int localCount, ref T value) |
override T | RGet (int index, int localCount) |
Gets an item at distance 'index' from the back (beginning of a VList) More... | |
override bool | RGet (int index, int localCount, ref T value) |
override T | Front (int localCount) |
Returns the "front" item in a FVList/FWList associated with this block (or back item of a VList) where localCount is the number of items in the FVList's first block. More... | |
override VListBlock< T > | Add (int localIndex, T item) |
Inserts a new item at the "front" of a FVList where localCount is the number of items currently in the FVList's first block. More... | |
override FVList< T > | SubList (int localIndex) |
Returns a list in which this[localIndex-1] is the first item. Nonpositive indexes are allowed and refer to prior lists; SubList returns an empty list if localIndex is so low that it goes past the back of the list. More... | |
override void | MuClear (int localCountWithMutables) |
Clears all mutable items in this chain, and clears the mutable flag. If this block owns mutable items in prior blocks, they are cleared too. More... | |
override FVList< T > | Where (int localCount, Predicate< T > keep, WListProtected< T > forWList) |
override FVList< T > | WhereSelect (int _localCount, Func< T, Maybe< T >> map, WListProtected< T > forWList) |
override FVList< T > | SmartSelect (int _localCount, Func< T, T > map, WListProtected< T > forWList) |
Public Member Functions inherited from Loyc.Collections.VListBlock< T > | |
FVList< T > | ReplaceAt (int localCount, T item, int distanceFromFront) |
Replaces an item in a FVList with another, where localCount is the number of items in the FVList's first block and distanceFromFront is the element index to replace (0=front). More... | |
FVList< T > | RemoveAt (int localCount, int distanceFromFront) |
Removes the specified number of items from a FVList where localCount is the number of items in the FVList's first block, distanceFromFront is the first removal position (minimum 0) and count is the number of items to remove. Of course, the terminology used here is to be understood in the context of a FVList (in which items are inserted at the front of the list). More... | |
FVList< T > | RemoveRange (int localCount, int distanceFromFront, int count) |
Protected Member Functions | |
override void | BlockToArray (T[] array, int arrayOffset, int localCount, bool isRList) |
Protected Member Functions inherited from Loyc.Collections.VListBlock< T > | |
VListBlock< T > | AddRange (FVList< T > front, FVList< T > back) |
Appends a range of items to the "front" of this block. More... | |
void | MuAddEmpty2 (WListProtected< T > w, int count, int newBlockSizeLimit) |
bool | IsSame (T old, Maybe< T > @new) |
Additional Inherited Members | |
Static Public Member Functions inherited from Loyc.Collections.VListBlock< T > | |
static VListBlock< T > | Add (VListBlock< T > self, int localCount, T item) |
Adds an item to the "front" of an immutable FVList. More... | |
static FVList< T > | SubList (VListBlock< T > self, int localCount, int offset) |
static FVList< T > | TailOf (FVList< T > list) |
static VListBlock< T > | Insert (VListBlock< T > self, int localCount, T item, int distanceFromFront) |
Inserts a new item in a FVList where localCount is the number of items in the FVList's first block and distanceFromFront is the insertion position (0=front). More... | |
static FVList< T > | InsertRange (VListBlock< T > self, int localCount, IList< T > items, int distanceFromFront, bool isRVList) |
Inserts a list of items in the middle of a FVList, where localCount is the number of items in the FVList's first block and distanceFromFront is the insertion position (0=front). More... | |
static VList< T > | AddRange (VListBlock< T > self, int localCount, IEnumerator< T > items) |
Adds a list of items to an immutable VList (not a FVList). More... | |
static FVList< T > | AddRange (VListBlock< T > self, int localCount, IList< T > items, bool isRVList) |
Adds a list of items to an immutable FVList. More... | |
static FVList< T > | AddRange (VListBlock< T > self, int localCount, FVList< T > front, FVList< T > back) |
Adds a range of items to a FVList where localCount is the number of items in the FVList's first block, front points to the beginning of the range to add and back points to the end of the range. More... | |
static FVList< T > | FindNextBlock (ref FVList< T > subList, FVList< T > list, out int localCountOfSubList) |
Finds the block that comes before 'subList' in the direction of the larger list, 'list'. More... | |
static VList< T > | FindNextBlock (ref VList< T > subList, VList< T > list, out int localCountOfSubList) |
static FVList< T > | BackUpOnce (FVList< T > subList, FVList< T > list) |
static VList< T > | BackUpOnce (VList< T > subList, VList< T > list) |
static FVList< T > | EnsureImmutable (VListBlock< T > self, int localCount) |
Returns an immutable FVList with the specified parameters, modifying blocks if necessary. More... | |
static void | EnsureMutable (WListProtected< T > w, int mutablesNeeded) |
Ensures that at least the specified number of items at the front of a FWList or WList are mutable and owned by the list. More... | |
static int | MutableCount (WListProtected< T > w) |
static void | MuAdd (WListProtected< T > w, T item) |
static void | MuAddEmpty (WListProtected< T > w, int count) |
static void | MuAddEmpty (WListProtected< T > w, int count, int newBlockSizeLimit) |
Adds empty item(s) to the front of the list. More... | |
static void | MuMove (WListProtected< T > w, int dffFrom, int dffTo, int count) |
Moves a series of elements from one location to another in a mutable block. More... | |
static void | MuRemoveFront (WListProtected< T > w, int count) |
static T[] | ToArray (VListBlock< T > self, int localCount, bool isRList) |
Converts any kind of FVList to an array, quickly. More... | |
static FVList< Out > | Select< Out > (VListBlock< T > _block, int _localCount, Func< T, Out > map, WListProtected< Out > forWList) |
static FVList< T > | Transform (VListBlock< T > _block, int _localCount, VListTransformer< T > x, bool isRList, WListProtected< T > forWList) |
Transforms a list (combines filtering with selection and more). More... | |
Static Protected Member Functions inherited from Loyc.Collections.VListBlock< T > | |
static int | MuAllocBlock (WListProtected< T > w, int newBlockSizeLimit) |
Used by MuAddEmpty to allocate an empty mutable block. More... | |
static FVList< T > | MakeResult (VListBlock< T > _block, int _localCount, WListProtected< T > forWList) |
static FVList< T > | MakeResult (T item, WListProtected< T > forWList) |
static FVList< T > | MakeResult (T _1, T _2, WListProtected< T > forWList) |
Protected fields inherited from Loyc.Collections.VListBlock< T > | |
int | _immCount |
number of immutable elements in our local array, plus a "mutable" flag in bit 30. More... | |
const int | MutableFlag = 0x40000000 |
const int | ImmCountMask = MutableFlag - 1 |
|
inline |
Initializes a mutable block with no items.
|
inline |
Initializes a block with two items.
The secondItem is added second, so it will occupy position [0] of a FVList or position [1] of a VList.
|
inlinevirtual |
Inserts a new item at the "front" of a FVList where localCount is the number of items currently in the FVList's first block.
Implements Loyc.Collections.VListBlock< T >.
|
inlinevirtual |
Gets an item at distance 'index' from the front (beginning of an FVList)
FGet and RGet were added as an optimization, to reduce the minimum number of virtual calls from 2 to 1 and to decrease the number of calculations involved in looking up an item.
Implements Loyc.Collections.VListBlock< T >.
|
inlinevirtual |
Returns the "front" item in a FVList/FWList associated with this block (or back item of a VList) where localCount is the number of items in the FVList's first block.
Implements Loyc.Collections.VListBlock< T >.
|
inlinevirtual |
Clears all mutable items in this chain, and clears the mutable flag. If this block owns mutable items in prior blocks, they are cleared too.
Clearing items is unnecessary if ImmCount is zero, as there there are no shared copies and the caller is going to discard the block, so it'll be garbage anyway.
Implements Loyc.Collections.VListBlock< T >.
|
inlinevirtual |
Gets an item at distance 'index' from the back (beginning of a VList)
Implements Loyc.Collections.VListBlock< T >.
|
inlinevirtual |
Returns a list in which this[localIndex-1] is the first item. Nonpositive indexes are allowed and refer to prior lists; SubList returns an empty list if localIndex is so low that it goes past the back of the list.
Warning: Normally FVList can only contain a reference to an immutable list, but this method can return a reference that includes mutable items.
Implements Loyc.Collections.VListBlock< T >.