C5  2.4
The C5 Generic Collection Library for C# and CLI is a comprehensive collection library supporting lists, sets, bags, dictionaries, priority queues, (FIFO) queues, and (LIFO) stacks. C5 runs on .NET 3.5+, Silverlight 5, Windows Phone 8, Xamarin.iOS, Xamarin.Android, and Mono.
C5.ArrayBase< T > Class Template Reference

Base class for collection classes of dynamic array type implementations. More...

Inheritance diagram for C5.ArrayBase< T >:
C5.SequencedBase< T > C5.DirectedCollectionBase< T > C5.IDirectedCollectionValue< T > C5.CollectionBase< T > C5.IDirectedCollectionValue< T > C5.ICollectionValue< T > C5.IDirectedEnumerable< T > C5.CollectionValueBase< T > C5.ICollectionValue< T > C5.IDirectedEnumerable< T > C5.IShowable C5.EnumerableBase< T > C5.ICollectionValue< T > C5.IShowable C5.IShowable C5.IShowable C5.ArrayList< T > C5.HashedArrayList< T > C5.SortedArray< T >

Classes

class  Range
 A helper class for defining results of interval queries on array based collections. More...
 

Public Member Functions

virtual void Clear ()
 Remove all items and reset size of internal array container. More...
 
override T[] ToArray ()
 Create an array containing (copies) of the items of this collection in enumeration order. More...
 
virtual bool Check ()
 Perform an internal consistency (invariant) test on the array base. More...
 
override IDirectedCollectionValue< T > Backwards ()
 Create a directed collection with the same contents as this one, but opposite enumeration sequence. More...
 
override T Choose ()
 Choose some item of this collection. The result is the last item in the internal array, making it efficient to remove. More...
 
override SCG.IEnumerator< T > GetEnumerator ()
 Create an enumerator for this array based collection. More...
 
- Public Member Functions inherited from C5.SequencedBase< T >
virtual int GetSequencedHashCode ()
 Get the sequenced collection hash code of this collection: from the cached value if present and up to date, else (re)compute. More...
 
virtual bool SequencedEquals (ISequenced< T > otherCollection)
 Check if the contents of that is equal to the contents of this in the sequenced sense. Using the item equalityComparer of this collection. More...
 
int FindIndex (Func< T, bool > predicate)
 Check if there exists an item that satisfies a specific predicate in this collection and return the index of the first one. More...
 
int FindLastIndex (Func< T, bool > predicate)
 Check if there exists an item that satisfies a specific predicate in this collection and return the index of the last one. More...
 
- Public Member Functions inherited from C5.DirectedCollectionBase< T >
virtual bool FindLast (Func< T, bool > predicate, out T item)
 Check if there exists an item that satisfies a specific predicate in this collection and return the first one in enumeration order. More...
 
- Public Member Functions inherited from C5.CollectionBase< T >
virtual int GetUnsequencedHashCode ()
 Get the unsequenced collection hash code of this collection: from the cached value if present and up to date, else (re)compute. More...
 
virtual bool UnsequencedEquals (ICollection< T > otherCollection)
 Check if the contents of otherCollection is equal to the contents of this in the unsequenced sense. Uses the item equality comparer of this collection More...
 
- Public Member Functions inherited from C5.CollectionValueBase< T >
virtual void CopyTo (T[] array, int index)
 Copy the items of this collection to part of an array. More...
 
virtual void Apply (Action< T > action)
 Apply an single argument action, T:Action`1 to this enumerable More...
 
virtual bool Exists (Func< T, bool > predicate)
 Check if there exists an item that satisfies a specific predicate in this collection. More...
 
virtual bool Find (Func< T, bool > predicate, out T item)
 Check if there exists an item that satisfies a specific predicate in this collection and return the first one in enumeration order. More...
 
virtual bool All (Func< T, bool > predicate)
 Check if all items in this collection satisfies a specific predicate. More...
 
virtual SCG.IEnumerable< T > Filter (Func< T, bool > predicate)
 Create an enumerable, enumerating the items of this collection that satisfies a certain condition. More...
 
virtual bool Show (System.Text.StringBuilder stringbuilder, ref int rest, IFormatProvider formatProvider)
 
virtual string ToString (string format, IFormatProvider formatProvider)
 
override string ToString ()
 
- Public Member Functions inherited from C5.IShowable
bool Show (StringBuilder stringbuilder, ref int rest, IFormatProvider formatProvider)
 Format More...
 

Protected Member Functions

virtual void expand ()
 Double the size of the internal array. More...
 
virtual void expand (int newcapacity, int newsize)
 Expand the internal array container. More...
 
virtual void InsertProtected (int i, T item)
 Insert an item at a specific index, moving items to the right upwards and expanding the array if necessary. More...
 
 ArrayBase (int capacity, SCG.IEqualityComparer< T > itemequalityComparer)
 Create an empty ArrayBase object. More...
 
- Protected Member Functions inherited from C5.SequencedBase< T >
 SequencedBase (SCG.IEqualityComparer< T > itemequalityComparer)
 
- Protected Member Functions inherited from C5.DirectedCollectionBase< T >
 DirectedCollectionBase (SCG.IEqualityComparer< T > itemequalityComparer)
 
- Protected Member Functions inherited from C5.CollectionBase< T >
 CollectionBase (SCG.IEqualityComparer< T > itemequalityComparer)
 
void checkRange (int start, int count)
 Utility method for range checking. More...
 
virtual void modifycheck (int thestamp)
 Check if the collection has been modified since a specified time, expressed as a stamp value. More...
 
virtual void updatecheck ()
 Check if it is valid to perform update operations, and if so increment stamp. More...
 
- Protected Member Functions inherited from C5.CollectionValueBase< T >
virtual void raiseCollectionChanged ()
 Fire the CollectionChanged event More...
 
virtual void raiseCollectionCleared (bool full, int count)
 Fire the CollectionCleared event More...
 
virtual void raiseCollectionCleared (bool full, int count, int?offset)
 Fire the CollectionCleared event More...
 
virtual void raiseItemsAdded (T item, int count)
 Fire the ItemsAdded event More...
 
virtual void raiseItemsRemoved (T item, int count)
 Fire the ItemsRemoved event More...
 
virtual void raiseItemInserted (T item, int index)
 Fire the ItemInserted event More...
 
virtual void raiseItemRemovedAt (T item, int index)
 Fire the ItemRemovedAt event More...
 
virtual void raiseForSetThis (int index, T value, T item)
 
virtual void raiseForInsert (int i, T item)
 
void raiseForRemove (T item)
 
void raiseForRemove (T item, int count)
 
void raiseForRemoveAt (int index, T item)
 
virtual void raiseForUpdate (T newitem, T olditem)
 
virtual void raiseForUpdate (T newitem, T olditem, int count)
 
virtual void raiseForAdd (T item)
 
virtual void raiseForRemoveAll (ICollectionValue< T > wasRemoved)
 

Protected Attributes

T[] array
 The actual internal array container. Will be extended on demand. More...
 
int offsetField
 The offset into the internal array container of the first item. The offset is 0 for a base dynamic array and may be positive for an updatable view into a base dynamic array. More...
 
- Protected Attributes inherited from C5.CollectionBase< T >
bool isReadOnlyBase = false
 The underlying field of the ReadOnly property More...
 
int stamp
 The current stamp value More...
 
int size
 The number of items in the collection More...
 
readonly SCG.IEqualityComparer< T > itemequalityComparer
 The item equalityComparer of the collection More...
 

Properties

virtual IDirectedCollectionValue< T > this[int start, int count] [get]
 
- Properties inherited from C5.SequencedBase< T >
override EnumerationDirection Direction [get]
 
- Properties inherited from C5.DirectedCollectionBase< T >
virtual EnumerationDirection Direction [get]
 
- Properties inherited from C5.CollectionBase< T >
virtual bool IsReadOnly [get]
 
override int Count [get]
 
override Speed CountSpeed [get]
 The value is symbolic indicating the type of asymptotic complexity in terms of the size of this collection (worst-case or amortized as relevant). More...
 
virtual SCG.IEqualityComparer< T > EqualityComparer [get]
 
override bool IsEmpty [get]
 
- Properties inherited from C5.CollectionValueBase< T >
virtual EventTypeEnum ListenableEvents [get]
 
virtual EventTypeEnum ActiveEvents [get]
 A flag bitmap of the events currently subscribed to by this collection. More...
 
virtual CollectionChangedHandler< T > CollectionChanged
 The change event. Will be raised for every change operation on the collection. More...
 
virtual CollectionClearedHandler< T > CollectionCleared
 The clear event. Will be raised for every Clear operation on the collection. More...
 
virtual ItemsAddedHandler< T > ItemsAdded
 The item added event. Will be raised for every individual addition to the collection. More...
 
virtual ItemsRemovedHandler< T > ItemsRemoved
 The item removed event. Will be raised for every individual removal from the collection. More...
 
virtual ItemInsertedHandler< T > ItemInserted
 The item added event. Will be raised for every individual addition to the collection. More...
 
virtual ItemRemovedAtHandler< T > ItemRemovedAt
 The item removed event. Will be raised for every individual removal from the collection. More...
 
abstract bool IsEmpty [get]
 Check if collection is empty. More...
 
abstract int Count [get]
 The number of items in this collection. More...
 
abstract Speed CountSpeed [get]
 The value is symbolic indicating the type of asymptotic complexity in terms of the size of this collection (worst-case or amortized as relevant). More...
 
- Properties inherited from C5.ICollectionValue< T >
EventTypeEnum ListenableEvents [get]
 A flag bitmap of the events subscribable to by this collection. More...
 
EventTypeEnum ActiveEvents [get]
 A flag bitmap of the events currently subscribed to by this collection. More...
 
bool IsEmpty [get]
 
int Count [get]
 
Speed CountSpeed [get]
 The value is symbolic indicating the type of asymptotic complexity in terms of the size of this collection (worst-case or amortized as relevant). More...
 
- Properties inherited from C5.IDirectedEnumerable< T >
EnumerationDirection Direction [get]
 

Additional Inherited Members

- Static Public Member Functions inherited from C5.SequencedBase< T >
static int ComputeHashCode (ISequenced< T > items, SCG.IEqualityComparer< T > itemequalityComparer)
 Compute the unsequenced hash code of a collection More...
 
static bool StaticEquals (ISequenced< T > collection1, ISequenced< T > collection2, SCG.IEqualityComparer< T > itemequalityComparer)
 Examine if tit and tat are equal as sequenced collections using the specified item equalityComparer (assumed compatible with the two collections). More...
 
- Static Public Member Functions inherited from C5.CollectionBase< T >
static int ComputeHashCode (ICollectionValue< T > items, SCG.IEqualityComparer< T > itemequalityComparer)
 Compute the unsequenced hash code of a collection More...
 
static bool StaticEquals (ICollection< T > collection1, ICollection< T > collection2, SCG.IEqualityComparer< T > itemequalityComparer)
 Examine if collection1 and collection2 are equal as unsequenced collections using the specified item equalityComparer (assumed compatible with the two collections). More...
 
- Static Protected Member Functions inherited from C5.EnumerableBase< T >
static int countItems (SCG.IEnumerable< T > items)
 Count the number of items in an enumerable by enumeration More...
 
- Events inherited from C5.ICollectionValue< T >
CollectionChangedHandler< T > CollectionChanged
 The change event. Will be raised for every change operation on the collection. More...
 
CollectionClearedHandler< T > CollectionCleared
 The change event. Will be raised for every clear operation on the collection. More...
 
ItemsAddedHandler< T > ItemsAdded
 The item added event. Will be raised for every individual addition to the collection. More...
 
ItemInsertedHandler< T > ItemInserted
 The item inserted event. Will be raised for every individual insertion to the collection. More...
 
ItemsRemovedHandler< T > ItemsRemoved
 The item removed event. Will be raised for every individual removal from the collection. More...
 
ItemRemovedAtHandler< T > ItemRemovedAt
 The item removed at event. Will be raised for every individual removal at from the collection. More...
 

Detailed Description

Base class for collection classes of dynamic array type implementations.

Constructor & Destructor Documentation

C5.ArrayBase< T >.ArrayBase ( int  capacity,
SCG.IEqualityComparer< T >  itemequalityComparer 
)
protected

Create an empty ArrayBase object.

Parameters
capacityThe initial capacity of the internal array container. Will be rounded upwards to the nearest power of 2 greater than or equal to 8.
itemequalityComparerThe item equalityComparer to use, primarily for item equality

Member Function Documentation

override IDirectedCollectionValue<T> C5.ArrayBase< T >.Backwards ( )
virtual

Create a directed collection with the same contents as this one, but opposite enumeration sequence.

Returns
The mirrored collection.

Implements C5.DirectedCollectionBase< T >.

virtual bool C5.ArrayBase< T >.Check ( )
virtual

Perform an internal consistency (invariant) test on the array base.

Returns
True if test succeeds.

Reimplemented in C5.HashedArrayList< T >, C5.ArrayList< T >, and C5.SortedArray< T >.

override T C5.ArrayBase< T >.Choose ( )

Choose some item of this collection. The result is the last item in the internal array, making it efficient to remove.

Exceptions
NoSuchItemExceptionif collection is empty.
Returns

Implements C5.ICollectionValue< T >.

virtual void C5.ArrayBase< T >.Clear ( )
virtual

Remove all items and reset size of internal array container.

Reimplemented in C5.HashedArrayList< T >, C5.ArrayList< T >, and C5.SortedArray< T >.

virtual void C5.ArrayBase< T >.expand ( )
protectedvirtual

Double the size of the internal array.

Reimplemented in C5.HashedArrayList< T >, and C5.ArrayList< T >.

virtual void C5.ArrayBase< T >.expand ( int  newcapacity,
int  newsize 
)
protectedvirtual

Expand the internal array container.

Parameters
newcapacityThe new size of the internal array - will be rounded upwards to a power of 2.
newsizeThe (new) size of the (base) collection.

Reimplemented in C5.HashedArrayList< T >, and C5.ArrayList< T >.

override SCG.IEnumerator<T> C5.ArrayBase< T >.GetEnumerator ( )
virtual

Create an enumerator for this array based collection.

Returns
The enumerator

Implements C5.SequencedBase< T >.

virtual void C5.ArrayBase< T >.InsertProtected ( int  i,
item 
)
protectedvirtual

Insert an item at a specific index, moving items to the right upwards and expanding the array if necessary.

Parameters
iThe index at which to insert.
itemThe item to insert.

Reimplemented in C5.HashedArrayList< T >, and C5.ArrayList< T >.

override T [] C5.ArrayBase< T >.ToArray ( )

Create an array containing (copies) of the items of this collection in enumeration order.

Returns
The new array

Implements C5.ICollectionValue< T >.

Member Data Documentation

T [] C5.ArrayBase< T >.array
protected

The actual internal array container. Will be extended on demand.

int C5.ArrayBase< T >.offsetField
protected

The offset into the internal array container of the first item. The offset is 0 for a base dynamic array and may be positive for an updatable view into a base dynamic array.

Property Documentation

virtual IDirectedCollectionValue<T> C5.ArrayBase< T >.this[int start, int count]
get

Exceptions
ArgumentOutOfRangeExceptionIf the arguments does not describe a valid range in the indexed collection, cf. M:C5.CollectionBase`1.checkRange(System.Int32,System.Int32).

The directed collection of items in a specific index interval.

Parameters
startThe low index of the interval (inclusive).
countThe size of the range.

The documentation for this class was generated from the following file: