Enhanced C#
Language of your choice: library documentation

Documentation moved to ecsharp.net

GitHub doesn't support HTTP redirects, so you'll be redirected in 3 seconds.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public fields | Properties | Public Member Functions | Protected Member Functions | List of all members
Loyc.Collections.VListBlockArray< T > Class Template Reference

Implementation of VListBlock(of T) that contains an array. It is always initialized with at least one item, and items cannot be removed unless the list is mutable. More...


Source file:
Inheritance diagram for Loyc.Collections.VListBlockArray< T >:
Loyc.Collections.VListBlock< T >

Remarks

Implementation of VListBlock(of T) that contains an array. It is always initialized with at least one item, and items cannot be removed unless the list is mutable.

_prior._block is never null because the last block in a chain is always a VListBlockOfTwo. _array is never null either and _priorCount is at least 2.

Public fields

const int MAX_BLOCK_LEN = 1024
 

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

 VListBlockArray (FVList< T > prior, T firstItem)
 Inits an immutable block with one item. More...
 
 VListBlockArray (FVList< T > prior, int localCapacity, bool mutable)
 Inits an empty block. 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...
 
- 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)
 
virtual FVList< T > Where (int _localCount, Predicate< T > map, WListProtected< T > forWList)
 
virtual FVList< T > SmartSelect (int _localCount, Func< T, T > map, WListProtected< T > forWList)
 
virtual FVList< T > WhereSelect (int _localCount, Func< T, Maybe< T >> map, WListProtected< T > forWList)
 

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
 

Constructor & Destructor Documentation

Loyc.Collections.VListBlockArray< T >.VListBlockArray ( FVList< T >  prior,
firstItem 
)
inline

Inits an immutable block with one item.

Loyc.Collections.VListBlockArray< T >.VListBlockArray ( FVList< T >  prior,
int  localCapacity,
bool  mutable 
)
inline

Inits an empty block.

Parameters
localCapacityMax item count in this block, or zero to let the constructor choose the capacity.

If this constructor is called directly, mutable must be true, because immutable blocks must have at least one item.

Member Function Documentation

override VListBlock<T> Loyc.Collections.VListBlockArray< T >.Add ( int  localCount,
item 
)
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 >.

override T Loyc.Collections.VListBlockArray< T >.FGet ( int  index,
int  localCount 
)
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 >.

override T Loyc.Collections.VListBlockArray< T >.Front ( int  localCount)
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 >.

override void Loyc.Collections.VListBlockArray< T >.MuClear ( int  localCountWithMutables)
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 >.

override T Loyc.Collections.VListBlockArray< T >.RGet ( int  index,
int  localCount 
)
inlinevirtual

Gets an item at distance 'index' from the back (beginning of a VList)

Implements Loyc.Collections.VListBlock< T >.

override FVList<T> Loyc.Collections.VListBlockArray< T >.SubList ( int  localIndex)
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 >.