Rebornbuddy
|
The SortableList allows to maintain a list sorted as long as needed. If no IComparer interface has been provided at construction, then the list expects the Objects to implement IComparer. If the list is not sorted it behaves like an ordinary list. When sorted, the list's "Add" method will put new objects at the right place. As well the "Contains" and "IndexOf" methods will perform a binary search. More...
Public Member Functions | |
SortableList () | |
Default constructor. Since no IComparer is provided here, added objects must implement the IComparer interface. | |
SortableList (int Capacity) | |
Constructor. Since no IComparer is provided, added objects must implement the IComparer interface. | |
SortableList (IComparer Comparer) | |
Constructor. | |
SortableList (IComparer Comparer, int Capacity) | |
Constructor. | |
int | Add (object O) |
IList implementation. If the KeepSorted property is set to true, the object will be added at the right place. Else it will be added at the end of the list. | |
bool | Contains (object O) |
IList implementation. Search for a specified object in the list. If the list is sorted, a BinarySearch is performed using IComparer interface. Else the Object.Equals implementation is used. | |
int | IndexOf (object O) |
IList implementation. Returns the index of the specified object in the list. If the list is sorted, a BinarySearch is performed using IComparer interface. Else the Object.Equals implementation of objects is used. | |
void | Clear () |
IList implementation. Idem ArrayList | |
void | Insert (int Index, object O) |
IList implementation. Inserts an objects at a specified index. Cannot be used if the list has its KeepSorted property set to true. | |
void | Remove (object Value) |
IList implementation. Idem ArrayList | |
void | RemoveAt (int Index) |
IList implementation. Idem ArrayList | |
void | CopyTo (Array array, int arrayIndex) |
IList.ICollection implementation. Idem ArrayList | |
IEnumerator | GetEnumerator () |
IList.IEnumerable implementation. Idem ArrayList | |
object | Clone () |
ICloneable implementation. Idem ArrayList | |
int | IndexOf (object O, int Start) |
Idem IndexOf(object), but starting at a specified position in the list. | |
delegate bool | Equality (object O1, object O2) |
Defines an equality for two objects. | |
int | IndexOf (object O, Equality AreEqual) |
Idem IndexOf(object), but with a specified equality function. | |
int | IndexOf (object O, int Start, Equality AreEqual) |
Idem IndexOf(object), but with a start index and a specified equality function. | |
override string | ToString () |
Object.ToString() override. Build a string to represent the list. | |
override bool | Equals (object O) |
Object.Equals() override. | |
override int | GetHashCode () |
Object.GetHashCode() override. | |
void | Sort () |
Sorts the elements in the list using ArrayList.Sort. Does nothing if the list is already sorted. | |
void | AddRange (ICollection C) |
If the KeepSorted property is set to true, the object will be added at the right place. Else it will be appended to the list. | |
void | InsertRange (int Index, ICollection C) |
Inserts a collection of objects at a specified index. Should not be used if the list is the KeepSorted property is set to true. | |
void | LimitNbOccurrences (object Value, int NbValuesToKeep) |
Limits the number of occurrences of a specified value. Same values are equals according to the Equals() method of objects in the list. The first occurrences encountered are kept. | |
void | RemoveDuplicates () |
Removes all duplicates in the list. Each value encountered will have only one representant. | |
int | IndexOfMin () |
Returns the object of the list whose value is minimum. | |
int | IndexOfMax () |
Returns the object of the list whose value is maximum. |
Properties | |
bool | IsSorted [get] |
'Get only' property that indicates if the list is sorted. | |
bool | KeepSorted [get, set] |
Get : Indicates if the list must be kept sorted from now on. Set : Tells the list if it must stay sorted or not. Impossible to set to true if the list is not sorted. KeepSorted==true implies that IsSorted==true. | |
bool | AddDuplicates [get, set] |
If set to true, it will not be possible to add an object to the list if its value is already in the list. | |
object | this[int Index] [get, set] |
IList implementation. Gets - or sets - object's value at a specified index. The set operation is impossible if the KeepSorted property is set to true. | |
bool | IsFixedSize [get] |
IList implementation. Idem ArrayList | |
bool | IsReadOnly [get] |
IList implementation. Idem ArrayList | |
int | Count [get] |
IList.ICollection implementation. Idem ArrayList | |
bool | IsSynchronized [get] |
IList.ICollection implementation. Idem ArrayList | |
object | SyncRoot [get] |
IList.ICollection implementation. Idem ArrayList | |
int | Capacity [get, set] |
Idem ArrayList |
The SortableList allows to maintain a list sorted as long as needed. If no IComparer interface has been provided at construction, then the list expects the Objects to implement IComparer. If the list is not sorted it behaves like an ordinary list. When sorted, the list's "Add" method will put new objects at the right place. As well the "Contains" and "IndexOf" methods will perform a binary search.
Pathfinding.SortableList.SortableList | ( | ) |
Default constructor. Since no IComparer is provided here, added objects must implement the IComparer interface.
Pathfinding.SortableList.SortableList | ( | int | Capacity | ) |
Constructor. Since no IComparer is provided, added objects must implement the IComparer interface.
Capacity | Capacity of the list (ArrayList.Capacity) |
Pathfinding.SortableList.SortableList | ( | IComparer | Comparer | ) |
Constructor.
Comparer | Will be used to compare added elements for sort and search operations. |
Pathfinding.SortableList.SortableList | ( | IComparer | Comparer, |
int | Capacity ) |
Constructor.
Comparer | Will be used to compare added elements for sort and search operations. |
Capacity | Capacity of the list (ArrayList.Capacity) |
int Pathfinding.SortableList.Add | ( | object | O | ) |
IList implementation. If the KeepSorted property is set to true, the object will be added at the right place. Else it will be added at the end of the list.
O | The object to add. |
ArgumentException | The SortableList is set to use object's IComparable interface, and the specifed object does not implement this interface. |
void Pathfinding.SortableList.AddRange | ( | ICollection | C | ) |
If the KeepSorted property is set to true, the object will be added at the right place. Else it will be appended to the list.
C | The object to add. |
ArgumentException | The SortableList is set to use object's IComparable interface, and the specifed object does not implement this interface. |
void Pathfinding.SortableList.Clear | ( | ) |
IList implementation. Idem ArrayList
object Pathfinding.SortableList.Clone | ( | ) |
ICloneable implementation. Idem ArrayList
bool Pathfinding.SortableList.Contains | ( | object | O | ) |
IList implementation. Search for a specified object in the list. If the list is sorted, a BinarySearch is performed using IComparer interface. Else the Object.Equals implementation is used.
O | The object to look for |
void Pathfinding.SortableList.CopyTo | ( | Array | array, |
int | arrayIndex ) |
IList.ICollection implementation. Idem ArrayList
array | |
arrayIndex |
delegate bool Pathfinding.SortableList.Equality | ( | object | O1, |
object | O2 ) |
Defines an equality for two objects.
override bool Pathfinding.SortableList.Equals | ( | object | O | ) |
Object.Equals() override.
IEnumerator Pathfinding.SortableList.GetEnumerator | ( | ) |
IList.IEnumerable implementation. Idem ArrayList
override int Pathfinding.SortableList.GetHashCode | ( | ) |
Object.GetHashCode() override.
int Pathfinding.SortableList.IndexOf | ( | object | O | ) |
IList implementation. Returns the index of the specified object in the list. If the list is sorted, a BinarySearch is performed using IComparer interface. Else the Object.Equals implementation of objects is used.
O | The object to locate. |
int Pathfinding.SortableList.IndexOf | ( | object | O, |
Equality | AreEqual ) |
Idem IndexOf(object), but with a specified equality function.
O | The object to locate. |
AreEqual | Equality function to use for the search. |
int Pathfinding.SortableList.IndexOf | ( | object | O, |
int | Start ) |
Idem IndexOf(object), but starting at a specified position in the list.
O | The object to locate. |
Start | The index for start position. |
int Pathfinding.SortableList.IndexOf | ( | object | O, |
int | Start, | ||
Equality | AreEqual ) |
Idem IndexOf(object), but with a start index and a specified equality function.
O | The object to locate. |
Start | The index for start position. |
AreEqual | Equality function to use for the search. |
int Pathfinding.SortableList.IndexOfMax | ( | ) |
Returns the object of the list whose value is maximum.
int Pathfinding.SortableList.IndexOfMin | ( | ) |
Returns the object of the list whose value is minimum.
void Pathfinding.SortableList.Insert | ( | int | Index, |
object | O ) |
IList implementation. Inserts an objects at a specified index. Cannot be used if the list has its KeepSorted property set to true.
Index | The index before which the object must be added. |
O | The object to add. |
ArgumentException | The SortableList is set to use object's IComparable interface, and the specifed object does not implement this interface. |
ArgumentOutOfRangeException | Index is less than zero or Index is greater than Count. |
InvalidOperationException | If the object is added at the specify index, the list will not be sorted any more and the KeepSorted property is set to true. |
void Pathfinding.SortableList.InsertRange | ( | int | Index, |
ICollection | C ) |
Inserts a collection of objects at a specified index. Should not be used if the list is the KeepSorted property is set to true.
Index | The index before which the objects must be added. |
C | The object to add. |
ArgumentException | The SortableList is set to use objects's IComparable interface, and the specifed object does not implement this interface. |
ArgumentOutOfRangeException | Index is less than zero or Index is greater than Count. |
InvalidOperationException | If the object is added at the specify index, the list will not be sorted any more and the KeepSorted property is set to true. |
void Pathfinding.SortableList.LimitNbOccurrences | ( | object | Value, |
int | NbValuesToKeep ) |
Limits the number of occurrences of a specified value. Same values are equals according to the Equals() method of objects in the list. The first occurrences encountered are kept.
Value | Value whose occurrences number must be limited. |
NbValuesToKeep | Number of occurrences to keep |
void Pathfinding.SortableList.Remove | ( | object | Value | ) |
IList implementation. Idem ArrayList
Value | The object whose value must be removed if found in the list. |
void Pathfinding.SortableList.RemoveAt | ( | int | Index | ) |
IList implementation. Idem ArrayList
Index | Index of object to remove. |
void Pathfinding.SortableList.RemoveDuplicates | ( | ) |
Removes all duplicates in the list. Each value encountered will have only one representant.
void Pathfinding.SortableList.Sort | ( | ) |
Sorts the elements in the list using ArrayList.Sort. Does nothing if the list is already sorted.
override string Pathfinding.SortableList.ToString | ( | ) |
Object.ToString() override. Build a string to represent the list.
|
getset |
If set to true, it will not be possible to add an object to the list if its value is already in the list.
|
getset |
Idem ArrayList
|
get |
IList.ICollection implementation. Idem ArrayList
|
get |
IList implementation. Idem ArrayList
|
get |
IList implementation. Idem ArrayList
|
get |
'Get only' property that indicates if the list is sorted.
|
get |
IList.ICollection implementation. Idem ArrayList
|
getset |
Get : Indicates if the list must be kept sorted from now on. Set : Tells the list if it must stay sorted or not. Impossible to set to true if the list is not sorted. KeepSorted==true implies that IsSorted==true.
InvalidOperationException | Cannot be set to true if the list is not sorted yet. |
|
get |
IList.ICollection implementation. Idem ArrayList
|
getset |
IList implementation. Gets - or sets - object's value at a specified index. The set operation is impossible if the KeepSorted property is set to true.
ArgumentOutOfRangeException | Index is less than zero or Index is greater than Count. |
InvalidOperationException | [] operator cannot be used to set a value if KeepSorted property is set to true. |