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.
- Template Parameters
-
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:
{ return Count - size - index; }
protected virtual IEnumerator<T> GetWListEnumerator()
{ return GetRVListEnumerator(); }
|
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 | AddRange (IEnumerator< T > items) |
|
void | RemoveAtDff (int distanceFromFront) |
|
void | RemoveRangeBase (int distanceFromFront, int count) |
|
void | AddRangeBase (IList< T > items, bool isRWList) |
|
void | InsertRangeAtDff (int distanceFromFront, IList< 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...
|
|
int Loyc.Collections.WListProtected< T >.IndexOf |
( |
T |
item | ) |
|
|
inlineprotected |
Searches for the specified object and returns the zero-based index of the first occurrence (lowest index) within the entire FVList.
- Parameters
-
item | Item to locate (can be null if T can be null) |
- Returns
- Index of the item, or -1 if it was not found.
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.
int Loyc.Collections.WListProtected< T >.BlockChainLength |
|
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.