|
Enhanced C#
Loyc library documentation
|
A simple base class that to helps you implement a "smart" collection. By default, all it does is forward every method to the underlying collection (including GetHashCode, Equals and ToString). You can change its behavior by overriding methods. More...
A simple base class that to helps you implement a "smart" collection. By default, all it does is forward every method to the underlying collection (including GetHashCode, Equals and ToString). You can change its behavior by overriding methods.
This could be used, for example, to help you implement a collection that needs to take some kind of action whenever the collection is modified.
| TList | : | IList<T> |
Properties | |
| virtual T | this[int index] [get, set] |
Properties inherited from Loyc.Collections.ISource< out T > | |
| new int | Count [get] |
| Gets the number of items in the collection. More... | |
Properties inherited from Loyc.Collections.ICount | |
| int | Count [get] |
| Gets the number of items in the collection. More... | |
Properties inherited from Loyc.Collections.IIsEmpty | |
| bool | IsEmpty [get] |
Properties inherited from Loyc.Collections.IIndexed< in K, out V > | |
| V | this[K key] [get] |
| Gets the value associated with the specified key. More... | |
Public Member Functions | |
| ListWrapper (TList wrappedObject) | |
| virtual void | Insert (int index, T item) |
| virtual void | RemoveAt (int index) |
| virtual int | IndexOf (T item) |
| virtual IListSource< T > | Slice (int start, int count=int.MaxValue) |
| Returns a sub-range of this list. More... | |
| virtual T | TryGet (int index, out bool fail) |
Public Member Functions inherited from Loyc.Collections.Impl.CollectionWrapper< T, TCollection > | |
| CollectionWrapper (TCollection collection) | |
| virtual void | Add (T item) |
| virtual void | Clear () |
| virtual bool | Remove (T item) |
| virtual bool | Contains (T item) |
| virtual void | CopyTo (T[] array, int arrayIndex) |
| virtual IEnumerator< T > | GetEnumerator () |
Public Member Functions inherited from Loyc.WrapperBase< T > | |
| override bool | Equals (object?obj) |
| Returns true iff the parameter 'obj' is a wrapper around an object that is equal to the object that this object wraps. More... | |
| override int | GetHashCode () |
| Returns the hashcode of the wrapped object. More... | |
| override string | ToString () |
| Returns ToString() of the wrapped object. More... | |
Public Member Functions inherited from Loyc.Collections.ITryGet< in K, out V > | |
| V | TryGet (K key, out bool fail) |
| Gets the item for the specified key or index, and does not throw an exception on failure. More... | |
Public Member Functions inherited from Loyc.Collections.ICollectionSource< T > | |
| void | CopyTo (T[] array, int arrayIndex) |
| Copies the elements of the collection to an Array, starting at a particular array index. More... | |
Public Member Functions inherited from Loyc.Collections.IContains< in T > | |
| bool | Contains (T item) |
| Returns true if and only if the collection contains the specified item. More... | |
Additional Inherited Members | |
Public fields inherited from Loyc.Collections.Impl.CollectionWrapper< T, TCollection > | |
| bool | IsEmpty => Count == 0 |
| virtual int | Count => _obj.Count |
| virtual bool | IsReadOnly => _obj.IsReadOnly |
Protected Member Functions inherited from Loyc.WrapperBase< T > | |
| WrapperBase (T wrappedObject) | |
Protected fields inherited from Loyc.Collections.Impl.CollectionWrapper< T, TCollection > | |
| TCollection | Collection => _obj |
Protected fields inherited from Loyc.WrapperBase< T > | |
| T | _obj |
Protected static fields inherited from Loyc.WrapperBase< T > | |
|
static readonly EqualityComparer< T > | TComp = EqualityComparer<T>.Default |
|
virtual |
Returns a sub-range of this list.
| start | The new range will start at this index in the current list (this location will be index [0] in the new range). |
| count | The desired number of elements in the new range, or int.MaxValue to get all elements until the end of the list. |
| ArgumentException | The start index was below zero. |
The (start, count) range is allowed to be invalid, as long as start is zero or above.
this.Count - start. Implementation note: do not compute (start + count) because it may overflow. Instead, test whether (count > this.Count - start). Most collections should use the following implementation:
IListSource<T> IListSource<T>.Slice(int start, int count) { return Slice(start, count); } public Slice_<T> Slice(int start, int count) { return new Slice_<T>(this, start, count); }
Implements Loyc.Collections.IListSource< out T >.
1.8.7