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.SortedArray< T > Class Template Reference

A collection class implementing a sorted dynamic array data structure. More...

Inheritance diagram for C5.SortedArray< T >:
C5.ArrayBase< T > C5.IIndexedSorted< T > C5.SequencedBase< T > C5.ISorted< T > C5.IIndexed< T > C5.DirectedCollectionBase< T > C5.IDirectedCollectionValue< T > C5.ISequenced< T > C5.ISequenced< T > C5.IDirectedCollectionValue< T > C5.ICollection< T > C5.IDirectedCollectionValue< T > C5.ICollection< T > C5.IDirectedEnumerable< T > C5.ICollectionValue< T > C5.IDirectedCollectionValue< T > C5.CollectionBase< T >

Public Member Functions

 SortedArray ()
 Create a dynamic sorted array with a natural comparer (and item equalityComparer, assumed compatible) More...
 
 SortedArray (int capacity)
 Create a dynamic sorted array with a natural comparer (and item equalityComparer, assumed compatible) and prescribed initial capacity. More...
 
 SortedArray (SCG.IComparer< T > comparer)
 Create a dynamic sorted array with an external comparer. More...
 
 SortedArray (int capacity, SCG.IComparer< T > comparer)
 Create a dynamic sorted array with an external comparer and prescribed initial capacity. More...
 
 SortedArray (int capacity, SCG.IComparer< T > comparer, SCG.IEqualityComparer< T > equalityComparer)
 Create a dynamic sorted array with an external comparer, an external item equalityComparer and prescribed initial capacity. This is the constructor to use if the collection will be used as item in a hash table based collection. More...
 
int CountFrom (T bot)
 Determine the number of items at or above a supplied threshold. More...
 
int CountFromTo (T bot, T top)
 Determine the number of items between two supplied thresholds. More...
 
int CountTo (T top)
 Determine the number of items below a supplied threshold. More...
 
IDirectedCollectionValue< T > RangeFrom (T bot)
 Query this sorted collection for items greater than or equal to a supplied value. More...
 
IDirectedCollectionValue< T > RangeFromTo (T bot, T top)
 Query this sorted collection for items between two supplied values. More...
 
IDirectedCollectionValue< T > RangeTo (T top)
 Query this sorted collection for items less than a supplied value. More...
 
IIndexedSorted< T > FindAll (Func< T, bool > f)
 Create a new indexed sorted collection consisting of the items of this indexed sorted collection satisfying a certain predicate. More...
 
IIndexedSorted< V > Map< V > (Func< T, V > m, SCG.IComparer< V > c)
 Create a new indexed sorted collection consisting of the results of mapping all items of this list.

Exceptions
ArgumentExceptionif the map is not increasing over the items of this collection (with respect to the two given comparison relations).
More...
 
bool TryPredecessor (T item, out T res)
 Find the strict predecessor of item in the sorted array, that is, the greatest item in the collection smaller than the item. More...
 
bool TrySuccessor (T item, out T res)
 Find the strict successor of item in the sorted array, that is, the least item in the collection greater than the supplied value. More...
 
bool TryWeakPredecessor (T item, out T res)
 Find the weak predecessor of item in the sorted array, that is, the greatest item in the collection smaller than or equal to the item. More...
 
bool TryWeakSuccessor (T item, out T res)
 Find the weak successor of item in the sorted array, that is, the least item in the collection greater than or equal to the supplied value. More...
 
Predecessor (T item)
 Find the strict predecessor in the sorted collection of a particular value, i.e. the largest item in the collection less than the supplied value. More...
 
Successor (T item)
 Find the strict successor in the sorted collection of a particular value, i.e. the least item in the collection greater than the supplied value. More...
 
WeakPredecessor (T item)
 Find the weak predecessor in the sorted collection of a particular value, i.e. the largest item in the collection less than or equal to the supplied value.

Exceptions
NoSuchItemExceptionif no such element exists (the supplied value is less than the minimum of this collection.)
More...
 
WeakSuccessor (T item)
 Find the weak successor in the sorted collection of a particular value, i.e. the least item in the collection greater than or equal to the supplied value. More...
 
bool Cut (IComparable< T > c, out T low, out bool lowIsValid, out T high, out bool highIsValid)
 Perform a search in the sorted collection for the ranges in which a non-increasing (i.e. weakly decreasing) function from the item type to More...
 
IDirectedCollectionValue< T > RangeAll ()
 Create a directed collection with the same items as this collection. More...
 
void AddSorted (SCG.IEnumerable< T > items)
 Add all the items from another collection with an enumeration order that is increasing in the items.

Exceptions
ArgumentExceptionif the enumerated items turns out not to be in increasing order.
More...
 
void RemoveRangeFrom (T low)
 Remove all items of this collection above or at a supplied threshold. More...
 
void RemoveRangeFromTo (T low, T hi)
 Remove all items of this collection between two supplied thresholds. More...
 
void RemoveRangeTo (T hi)
 Remove all items of this collection below a supplied threshold. More...
 
override void Clear ()
 Remove all items from this collection, resetting internal array size. More...
 
bool Contains (T item)
 Check if this collection contains (an item equivalent according to the itemequalityComparer) to a particular value. More...
 
bool Find (ref T item)
 Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, return in the ref argument (a binary copy of) the actual value found. More...
 
bool FindOrAdd (ref T item)
 Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, return in the ref argument (a binary copy of) the actual value found. Else, add the item to the collection. More...
 
bool Update (T item)
 Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection to with a binary copy of the supplied value. If the collection has bag semantics, it is implementation dependent if this updates all equivalent copies in the collection or just one. More...
 
bool Update (T item, out T olditem)
 
bool UpdateOrAdd (T item)
 Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection to with a binary copy of the supplied value; else add the value to the collection. More...
 
bool UpdateOrAdd (T item, out T olditem)
 
bool Remove (T item)
 Remove a particular item from this collection. If the collection has bag semantics only one copy equivalent to the supplied item is removed. More...
 
bool Remove (T item, out T removeditem)
 Remove a particular item from this collection if found. If the collection has bag semantics only one copy equivalent to the supplied item is removed, which one is implementation dependent. If an item was removed, report a binary copy of the actual item removed in the argument. More...
 
void RemoveAll (SCG.IEnumerable< T > items)
 Remove all items in another collection from this one. More...
 
void RetainAll (SCG.IEnumerable< T > items)
 Remove all items not in some other collection from this one. More...
 
bool ContainsAll (SCG.IEnumerable< T > items)
 Check if this collection contains all the values in another collection. Multiplicities are not taken into account. More...
 
int ContainsCount (T item)
 Count the number of items of the collection equal to a particular value. Returns 0 if and only if the value is not in the collection. More...
 
virtual ICollectionValue< T > UniqueItems ()
 
virtual ICollectionValue< KeyValuePair< T, int > > ItemMultiplicities ()
 
void RemoveAllCopies (T item)
 Remove all (0 or 1) items equivalent to a given value. More...
 
override bool Check ()
 Check the integrity of the internal data structures of this collection. Only available in DEBUG builds??? More...
 
bool Add (T item)
 Add an item to this collection if possible. If this collection has set semantics, the item will be added if not already in the collection. If bag semantics, the item will always be added. More...
 
void AddAll (SCG.IEnumerable< T > items)
 Add the elements from another collection with a more specialized item type to this collection. Since this collection has set semantics, only items not already in the collection will be added. More...
 
FindMin ()
 Find the current least item of this priority queue. More...
 
DeleteMin ()
 Remove the least item from this priority queue. More...
 
FindMax ()
 Find the current largest item of this priority queue. More...
 
DeleteMax ()
 Remove the largest item from this priority queue. More...
 
int IndexOf (T item)
 Searches for an item in the list going forwards from the start. More...
 
int LastIndexOf (T item)
 Searches for an item in the list going backwards from the end. More...
 
RemoveAt (int i)
 Remove the item at a specific position of the list.

Exceptions
IndexOutOfRangeExceptionif i is negative or >= the size of the collection.
More...
 
void RemoveInterval (int start, int count)
 Remove all items in an index interval.

Exceptions
IndexOutOfRangeException???.
More...
 
- Public Member Functions inherited from C5.ArrayBase< T >
override T[] ToArray ()
 Create an array containing (copies) of the items of this collection in enumeration order. 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...
 
- Public Member Functions inherited from C5.ISequenced< T >
int GetSequencedHashCode ()
 The hashcode is defined as More...
 
bool SequencedEquals (ISequenced< T > otherCollection)
 Compare this sequenced collection to another one in sequence order. More...
 
- Public Member Functions inherited from C5.ICollection< T >
new void CopyTo (T[] array, int index)
 Copy the items of this collection to a contiguous part of an array. More...
 
int GetUnsequencedHashCode ()
 The unordered collection hashcode is defined as the sum of More...
 
bool UnsequencedEquals (ICollection< T > otherCollection)
 Compare the contents of this collection to another one without regards to the sequence order. The comparison will use this collection's itemequalityComparer to compare individual items. More...
 
- Public Member Functions inherited from C5.IIndexed< T >
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...
 

Properties

override EventTypeEnum ListenableEvents [get]
 
Speed ContainsSpeed [get]
 The value is symbolic indicating the type of asymptotic complexity in terms of the size of this collection (worst-case). More...
 
bool AllowsDuplicates [get]
 
virtual bool DuplicatesByCounting [get]
 By convention this is true for any collection with set semantics. More...
 
SCG.IComparer< T > Comparer [get]
 The comparer object supplied at creation time for this collection More...
 
this[int i] [get]
 
Exceptions
IndexOutOfRangeExceptionif i is negative or >= the size of the collection.
More...
 
virtual Speed IndexingSpeed [get]
 
- Properties inherited from C5.ArrayBase< T >
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]
 
- Properties inherited from C5.ISorted< T >
SCG.IComparer< T > Comparer [get]
 The comparer object supplied at creation time for this sorted collection. More...
 
- Properties inherited from C5.ICollection< T >
Speed ContainsSpeed [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...
 
new int Count [get]
 
new bool IsReadOnly [get]
 If true any call of an updating operation will throw an More...
 
- Properties inherited from C5.IExtensible< T >
bool IsReadOnly [get]
 If true any call of an updating operation will throw an More...
 
bool AllowsDuplicates [get]
 
SCG.IEqualityComparer< T > EqualityComparer [get]
 (Here should be a discussion of the role of equalityComparers. Any ). More...
 
bool DuplicatesByCounting [get]
 By convention this is true for any collection with set semantics. More...
 
- Properties inherited from C5.IIndexed< T >
Speed IndexingSpeed [get]
 
IDirectedCollectionValue< T > this[int start, int count] [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...
 
- Protected Member Functions inherited from C5.ArrayBase< T >
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)
 
- 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...
 
- Protected Attributes inherited from C5.ArrayBase< T >
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...
 
- 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

A collection class implementing a sorted dynamic array data structure.

Constructor & Destructor Documentation

Create a dynamic sorted array with a natural comparer (and item equalityComparer, assumed compatible)

Exceptions
NotComparableExceptionIf
T
is not comparable.
C5.SortedArray< T >.SortedArray ( int  capacity)

Create a dynamic sorted array with a natural comparer (and item equalityComparer, assumed compatible) and prescribed initial capacity.

Exceptions
NotComparableExceptionIf
T
is not comparable.
Parameters
capacityThe capacity
C5.SortedArray< T >.SortedArray ( SCG.IComparer< T >  comparer)

Create a dynamic sorted array with an external comparer.

The itemequalityComparer will be compatible T:C5.ComparerZeroHashCodeEqualityComparer`1 since the default equalityComparer for T (P:C5.EqualityComparer`1.Default) is unlikely to be compatible with the external comparer. This makes the array inadequate for use as item in a collection of unsequenced or sequenced sets or bags (T:C5.ICollection`1 and T:C5.ISequenced`1)

Parameters
comparerThe comparer
C5.SortedArray< T >.SortedArray ( int  capacity,
SCG.IComparer< T >  comparer 
)

Create a dynamic sorted array with an external comparer and prescribed initial capacity.

The itemequalityComparer will be a compatible T:C5.ComparerZeroHashCodeEqualityComparer`1 since the default equalityComparer for T (P:C5.EqualityComparer`1.Default) is unlikely to be compatible with the external comparer. This makes the sorted array inadequate for use as item in a collection of unsequenced or sequenced sets or bags (T:C5.ICollection`1 and T:C5.ISequenced`1)

Parameters
capacityThe capacity
comparerThe comparer
C5.SortedArray< T >.SortedArray ( int  capacity,
SCG.IComparer< T >  comparer,
SCG.IEqualityComparer< T >  equalityComparer 
)

Create a dynamic sorted array with an external comparer, an external item equalityComparer and prescribed initial capacity. This is the constructor to use if the collection will be used as item in a hash table based collection.

Parameters
capacityThe capacity
comparerThe item comparer
equalityComparerThe item equalityComparer (assumed compatible)

Member Function Documentation

bool C5.SortedArray< T >.Add ( item)

Add an item to this collection if possible. If this collection has set semantics, the item will be added if not already in the collection. If bag semantics, the item will always be added.

Parameters
itemThe item to add.
Returns
True if item was added.

Implements C5.ICollection< T >.

void C5.SortedArray< T >.AddAll ( SCG.IEnumerable< T >  items)

Add the elements from another collection with a more specialized item type to this collection. Since this collection has set semantics, only items not already in the collection will be added.

Parameters
itemsThe items to add

Implements C5.IExtensible< T >.

void C5.SortedArray< T >.AddSorted ( SCG.IEnumerable< T >  items)

Add all the items from another collection with an enumeration order that is increasing in the items.

Exceptions
ArgumentExceptionif the enumerated items turns out not to be in increasing order.

Parameters
itemsThe collection to add.

Implements C5.ISorted< T >.

override bool C5.SortedArray< T >.Check ( )
virtual

Check the integrity of the internal data structures of this collection. Only available in DEBUG builds???

Returns
True if check does not fail.

Reimplemented from C5.ArrayBase< T >.

override void C5.SortedArray< T >.Clear ( )
virtual

Remove all items from this collection, resetting internal array size.

Reimplemented from C5.ArrayBase< T >.

bool C5.SortedArray< T >.Contains ( item)

Check if this collection contains (an item equivalent according to the itemequalityComparer) to a particular value.

Parameters
itemThe value to check for.
Returns
True if the items is in this collection.

Implements C5.ICollection< T >.

bool C5.SortedArray< T >.ContainsAll ( SCG.IEnumerable< T >  items)

Check if this collection contains all the values in another collection. Multiplicities are not taken into account.

Parameters
itemsThe
Returns
True if all values in
items
is in this collection.

Implements C5.ICollection< T >.

int C5.SortedArray< T >.ContainsCount ( item)

Count the number of items of the collection equal to a particular value. Returns 0 if and only if the value is not in the collection.

Parameters
itemThe value to count.
Returns
The number of copies found (0 or 1).

Implements C5.ICollection< T >.

int C5.SortedArray< T >.CountFrom ( bot)

Determine the number of items at or above a supplied threshold.

Parameters
botThe lower bound (inclusive)
Returns
The number of matching items.

Implements C5.IIndexedSorted< T >.

int C5.SortedArray< T >.CountFromTo ( bot,
top 
)

Determine the number of items between two supplied thresholds.

Parameters
botThe lower bound (inclusive)
topThe upper bound (exclusive)
Returns
The number of matching items.

Implements C5.IIndexedSorted< T >.

int C5.SortedArray< T >.CountTo ( top)

Determine the number of items below a supplied threshold.

Parameters
topThe upper bound (exclusive)
Returns
The number of matching items.

Implements C5.IIndexedSorted< T >.

bool C5.SortedArray< T >.Cut ( IComparable< T >  c,
out T  low,
out bool  lowIsValid,
out T  high,
out bool  highIsValid 
)

Perform a search in the sorted collection for the ranges in which a non-increasing (i.e. weakly decreasing) function from the item type to

int is negative, zero respectively positive. If the supplied cut function is not non-increasing, the result of this call is undefined.

Parameters
cThe cut function
T
to
int
, given as an
IComparable<T>
object, where the cut function is the
c.CompareTo(T that)
method.
lowReturns the largest item in the collection, where the cut function is positive (if any).
lowIsValidTrue if the cut function is positive somewhere on this collection.
highReturns the least item in the collection, where the cut function is negative (if any).
highIsValidTrue if the cut function is negative somewhere on this collection.
Returns

Implements C5.ISorted< T >.

T C5.SortedArray< T >.DeleteMax ( )

Remove the largest item from this priority queue.

Returns
The removed item.

Implements C5.ISorted< T >.

T C5.SortedArray< T >.DeleteMin ( )

Remove the least item from this priority queue.

Returns
The removed item.

Implements C5.ISorted< T >.

bool C5.SortedArray< T >.Find ( ref T  item)

Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, return in the ref argument (a binary copy of) the actual value found.

Parameters
itemThe value to look for.
Returns
True if the items is in this collection.

Implements C5.ICollection< T >.

IIndexedSorted<T> C5.SortedArray< T >.FindAll ( Func< T, bool >  f)

Create a new indexed sorted collection consisting of the items of this indexed sorted collection satisfying a certain predicate.

Parameters
fThe filter delegate defining the predicate.
Returns
The new indexed sorted collection.

Implements C5.IIndexedSorted< T >.

T C5.SortedArray< T >.FindMax ( )

Find the current largest item of this priority queue.

Returns
The largest item.

Implements C5.ISorted< T >.

T C5.SortedArray< T >.FindMin ( )

Find the current least item of this priority queue.

Returns
The least item.

Implements C5.ISorted< T >.

bool C5.SortedArray< T >.FindOrAdd ( ref T  item)

Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, return in the ref argument (a binary copy of) the actual value found. Else, add the item to the collection.

Parameters
itemThe value to look for.
Returns
True if the item was added (hence not found).

Implements C5.ICollection< T >.

int C5.SortedArray< T >.IndexOf ( item)

Searches for an item in the list going forwards from the start.

Parameters
itemItem to search for.
Returns
Index of item from start.

Implements C5.IIndexed< T >.

virtual ICollectionValue<KeyValuePair<T, int> > C5.SortedArray< T >.ItemMultiplicities ( )
virtual

Returns

Implements C5.ICollection< T >.

int C5.SortedArray< T >.LastIndexOf ( item)

Searches for an item in the list going backwards from the end.

Parameters
itemItem to search for.
Returns
Index of of item from the end.

Implements C5.IIndexed< T >.

IIndexedSorted<V> C5.SortedArray< T >.Map< V > ( Func< T, V >  m,
SCG.IComparer< V >  c 
)

Create a new indexed sorted collection consisting of the results of mapping all items of this list.

Exceptions
ArgumentExceptionif the map is not increasing over the items of this collection (with respect to the two given comparison relations).

Parameters
mThe delegate definging the map.
cThe comparion relation to use for the result.
Returns
The new sorted collection.

Implements C5.IIndexedSorted< T >.

T C5.SortedArray< T >.Predecessor ( item)

Find the strict predecessor in the sorted collection of a particular value, i.e. the largest item in the collection less than the supplied value.

Exceptions
NoSuchItemExceptionif no such element exists (the supplied value is less than or equal to the minimum of this collection.)
Parameters
itemThe item to find the predecessor for.
Returns
The predecessor.

Implements C5.ISorted< T >.

Create a directed collection with the same items as this collection.

Returns
The result directed collection.

Implements C5.ISorted< T >.

IDirectedCollectionValue<T> C5.SortedArray< T >.RangeFrom ( bot)

Query this sorted collection for items greater than or equal to a supplied value.

Parameters
botThe lower bound (inclusive).
Returns
The result directed collection.

Implements C5.IIndexedSorted< T >.

IDirectedCollectionValue<T> C5.SortedArray< T >.RangeFromTo ( bot,
top 
)

Query this sorted collection for items between two supplied values.

Parameters
botThe lower bound (inclusive).
topThe upper bound (exclusive).
Returns
The result directed collection.

Implements C5.IIndexedSorted< T >.

IDirectedCollectionValue<T> C5.SortedArray< T >.RangeTo ( top)

Query this sorted collection for items less than a supplied value.

Parameters
topThe upper bound (exclusive).
Returns
The result directed collection.

Implements C5.IIndexedSorted< T >.

bool C5.SortedArray< T >.Remove ( item)

Remove a particular item from this collection. If the collection has bag semantics only one copy equivalent to the supplied item is removed.

Parameters
itemThe value to remove.
Returns
True if the item was found (and removed).

Implements C5.ICollection< T >.

bool C5.SortedArray< T >.Remove ( item,
out T  removeditem 
)

Remove a particular item from this collection if found. If the collection has bag semantics only one copy equivalent to the supplied item is removed, which one is implementation dependent. If an item was removed, report a binary copy of the actual item removed in the argument.

Parameters
itemThe value to remove.
removeditemThe removed value.
Returns
True if the item was found (and removed).

Implements C5.ICollection< T >.

void C5.SortedArray< T >.RemoveAll ( SCG.IEnumerable< T >  items)

Remove all items in another collection from this one.

Parameters
itemsThe items to remove.

Implements C5.ICollection< T >.

void C5.SortedArray< T >.RemoveAllCopies ( item)

Remove all (0 or 1) items equivalent to a given value.

Parameters
itemThe value to remove.

Implements C5.ICollection< T >.

T C5.SortedArray< T >.RemoveAt ( int  i)

Remove the item at a specific position of the list.

Exceptions
IndexOutOfRangeExceptionif i is negative or >= the size of the collection.

Parameters
iThe index of the item to remove.
Returns
The removed item.

Implements C5.IIndexed< T >.

void C5.SortedArray< T >.RemoveInterval ( int  start,
int  count 
)

Remove all items in an index interval.

Exceptions
IndexOutOfRangeException???.

Parameters
startThe index of the first item to remove.
countThe number of items to remove.

Implements C5.IIndexed< T >.

void C5.SortedArray< T >.RemoveRangeFrom ( low)

Remove all items of this collection above or at a supplied threshold.

Parameters
lowThe lower threshold (inclusive).

Implements C5.ISorted< T >.

void C5.SortedArray< T >.RemoveRangeFromTo ( low,
hi 
)

Remove all items of this collection between two supplied thresholds.

Parameters
lowThe lower threshold (inclusive).
hiThe upper threshold (exclusive).

Implements C5.ISorted< T >.

void C5.SortedArray< T >.RemoveRangeTo ( hi)

Remove all items of this collection below a supplied threshold.

Parameters
hiThe upper threshold (exclusive).

Implements C5.ISorted< T >.

void C5.SortedArray< T >.RetainAll ( SCG.IEnumerable< T >  items)

Remove all items not in some other collection from this one.

Parameters
itemsThe items to retain.

Implements C5.ICollection< T >.

T C5.SortedArray< T >.Successor ( item)

Find the strict successor in the sorted collection of a particular value, i.e. the least item in the collection greater than the supplied value.

Exceptions
NoSuchItemExceptionif no such element exists (the supplied value is greater than or equal to the maximum of this collection.)
Parameters
itemThe item to find the successor for.
Returns
The successor.

Implements C5.ISorted< T >.

bool C5.SortedArray< T >.TryPredecessor ( item,
out T  res 
)

Find the strict predecessor of item in the sorted array, that is, the greatest item in the collection smaller than the item.

Parameters
itemThe item to find the predecessor for.
resThe predecessor, if any; otherwise the default value for T.
Returns
True if item has a predecessor; otherwise false.

Implements C5.ISorted< T >.

bool C5.SortedArray< T >.TrySuccessor ( item,
out T  res 
)

Find the strict successor of item in the sorted array, that is, the least item in the collection greater than the supplied value.

Parameters
itemThe item to find the successor for.
resThe successor, if any; otherwise the default value for T.
Returns
True if item has a successor; otherwise false.

Implements C5.ISorted< T >.

bool C5.SortedArray< T >.TryWeakPredecessor ( item,
out T  res 
)

Find the weak predecessor of item in the sorted array, that is, the greatest item in the collection smaller than or equal to the item.

Parameters
itemThe item to find the weak predecessor for.
resThe weak predecessor, if any; otherwise the default value for T.
Returns
True if item has a weak predecessor; otherwise false.

Implements C5.ISorted< T >.

bool C5.SortedArray< T >.TryWeakSuccessor ( item,
out T  res 
)

Find the weak successor of item in the sorted array, that is, the least item in the collection greater than or equal to the supplied value.

Parameters
itemThe item to find the weak successor for.
resThe weak successor, if any; otherwise the default value for T.
Returns
True if item has a weak successor; otherwise false.

Implements C5.ISorted< T >.

virtual ICollectionValue<T> C5.SortedArray< T >.UniqueItems ( )
virtual

Returns

Implements C5.ICollection< T >.

bool C5.SortedArray< T >.Update ( item)

Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection to with a binary copy of the supplied value. If the collection has bag semantics, it is implementation dependent if this updates all equivalent copies in the collection or just one.

Parameters
itemValue to update.
Returns
True if the item was found and hence updated.

Implements C5.ICollection< T >.

bool C5.SortedArray< T >.Update ( item,
out T  olditem 
)

Parameters
item
olditem
Returns

Implements C5.ICollection< T >.

bool C5.SortedArray< T >.UpdateOrAdd ( item)

Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection to with a binary copy of the supplied value; else add the value to the collection.

Parameters
itemValue to add or update.
Returns
True if the item was found and updated (hence not added).

Implements C5.ICollection< T >.

bool C5.SortedArray< T >.UpdateOrAdd ( item,
out T  olditem 
)

Parameters
item
olditem
Returns

Implements C5.ICollection< T >.

T C5.SortedArray< T >.WeakPredecessor ( item)

Find the weak predecessor in the sorted collection of a particular value, i.e. the largest item in the collection less than or equal to the supplied value.

Exceptions
NoSuchItemExceptionif no such element exists (the supplied value is less than the minimum of this collection.)

Parameters
itemThe item to find the weak predecessor for.
Returns
The weak predecessor.

Implements C5.ISorted< T >.

T C5.SortedArray< T >.WeakSuccessor ( item)

Find the weak successor in the sorted collection of a particular value, i.e. the least item in the collection greater than or equal to the supplied value.

Exceptions
NoSuchItemExceptionif no such element exists (the supplied value is greater than the maximum of this collection.)
Parameters
itemThe item to find the weak successor for.
Returns
The weak successor.

Implements C5.ISorted< T >.

Property Documentation

bool C5.SortedArray< T >.AllowsDuplicates
get

False since this collection has set semantics

SCG.IComparer<T> C5.SortedArray< T >.Comparer
get

The comparer object supplied at creation time for this collection

The comparer

Speed C5.SortedArray< T >.ContainsSpeed
get

The value is symbolic indicating the type of asymptotic complexity in terms of the size of this collection (worst-case).

Speed.Log

virtual bool C5.SortedArray< T >.DuplicatesByCounting
get

By convention this is true for any collection with set semantics.

True if only one representative of a group of equal items is kept in the collection together with the total count.

virtual Speed C5.SortedArray< T >.IndexingSpeed
get

override EventTypeEnum C5.SortedArray< T >.ListenableEvents
get

T C5.SortedArray< T >.this[int i]
get

Exceptions
IndexOutOfRangeExceptionif i is negative or >= the size of the collection.

The i'th item of this list.

Parameters
ithe index to lookup

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