Enhanced C#
Language of your choice: library documentation
|
WList implementation in which the WList operations are only accessible to a derived class. More...
WList implementation in which the WList operations are only accessible to a derived class.
T | The type of elements in the list |
This base class is used in the same way one would use protected inheritance in C++: it provides the derived class with access to a FWList/WList, but it does not allow users of the derived class to access the list.
I had planned to use this base class as an optimization to help implement Loyc trees, but I didn't end up using it. Still, it could be useful someday as a base class of a memory-critical class that wants a mutable WList.
By default, the list will act like a FWList. If you want the list to act like an WList instead, override AdjustWListIndex and GetWListEnumerator as follows:
Properties | |
byte | UserByte [get, set] |
An additional byte that the derived class can optionally use. More... | |
int? | BlockChainLength [get] |
Gets the number of blocks used by this list. More... | |
Protected Member Functions | |
virtual int | AdjustWListIndex (int index, int size) |
This method implements the difference between FWList and WList: In FWList it returns index , but in WList it returns Count-size-index . More... | |
WListProtected (WListProtected< T > original, bool takeOwnership) | |
T | GetAt (int index) |
Gets an item from a FWList or WList at the specified index. More... | |
void | SetAt (int index, T value) |
Sets an item in a FWList or WList at the specified index. More... | |
void | Add (T item) |
Inserts an item at the "front" of the list, which is index 0 for FWList, or Count for WList. More... | |
void | Insert (int index, T item) |
void | RemoveAt (int index) |
int | IndexOf (T item) |
Searches for the specified object and returns the zero-based index of the first occurrence (lowest index) within the entire FVList. More... | |
bool | Contains (T item) |
void | CopyTo (T[] array, int arrayIndex) |
bool | Remove (T item) |
virtual IEnumerator< T > | GetIEnumerator () |
FVList< T >.Enumerator | GetVListEnumerator () |
VList< T >.Enumerator | GetRVListEnumerator () |
void | RemoveAtDff (int distanceFromFront) |
void | RemoveRangeBase (int distanceFromFront, int count) |
void | InsertRangeAtDff (int distanceFromFront, IReadOnlyList< T > items, bool isRWList) |
void | InsertAtDff (int distanceFromFront, T item) |
T | GetAtDff (int distanceFromFront) |
Gets an item WITHOUT doing a range check More... | |
void | SetAtDff (int distanceFromFront, T item) |
Sets an item WITHOUT doing a range or mutability check More... | |
FVList< T > | ToFVList () |
Returns this list as a FVList; if this is a WList, the order of the elements is reversed at the same time. More... | |
VList< T > | ToVList () |
Returns this list as a VList; if this is a FWList, the order of the elements is reversed at the same time. More... | |
|
inlineprotected |
|
inlineprotectedvirtual |
This method implements the difference between FWList and WList: In FWList it returns index
, but in WList it returns Count-size-index
.
index | Index to adjust |
size | Number of elements being accessed or removed |
Solely as an optimization, FWList and WList also have separate versions of this[], InsertAt and RemoveAt.
Reimplemented in Loyc.Collections.WList< T >, and Loyc.Collections.FWList< T >.
Referenced by Loyc.Collections.WListProtected< T >.GetAt(), and Loyc.Collections.WListProtected< T >.SetAt().
|
inlineprotected |
Gets an item from a FWList or WList at the specified index.
References Loyc.Collections.WListProtected< T >.AdjustWListIndex(), and Loyc.Collections.WListProtected< T >.GetAtDff().
|
inlineprotected |
Gets an item WITHOUT doing a range check
Referenced by Loyc.Collections.WListProtected< T >.GetAt().
|
inlineprotected |
Searches for the specified object and returns the zero-based index of the first occurrence (lowest index) within the entire FVList.
item | Item to locate (can be null if T can be null) |
This method determines equality using the default equality comparer EqualityComparer.Default for T, the type of values in the list.
This method performs a linear search; therefore, this method is an O(n) operation, where n is Count.
|
inlineprotected |
Sets an item in a FWList or WList at the specified index.
References Loyc.Collections.WListProtected< T >.AdjustWListIndex(), Loyc.Collections.VListBlock< T >.EnsureMutable(), and Loyc.Collections.WListProtected< T >.SetAtDff().
|
inlineprotected |
Sets an item WITHOUT doing a range or mutability check
Referenced by Loyc.Collections.WListProtected< T >.SetAt().
|
inlineprotected |
Returns this list as a FVList; if this is a WList, the order of the elements is reversed at the same time.
This operation marks the items of the FWList or WList as immutable. You can still modify the list afterward, but some or all of the list may have to be copied.
References Loyc.Collections.VListBlock< T >.EnsureImmutable().
|
inlineprotected |
Returns this list as a VList; if this is a FWList, the order of the elements is reversed at the same time.
This operation marks the items of the FWList or WList as immutable. You can still modify the list afterward, but some or all of the list may have to be copied.
References Loyc.Collections.VListBlock< T >.EnsureImmutable().
|
getprotected |
Gets the number of blocks used by this list.
You might look at this property when optimizing your program, because the runtime of some operations increases as the chain length increases. This property runs in O(BlockChainLength) time. Ideally, BlockChainLength is proportional to log_2(Count), but if you produced the FWList by converting it from a FVList, certain FVList usage patterns can produce long chains.
|
getsetprotected |
An additional byte that the derived class can optionally use.
Used by Loyc.