Click or drag to resize

SortableList Class

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.
Inheritance Hierarchy
SystemObject
  PathfindingSortableList

Namespace:  Pathfinding
Assembly:  RebornBuddy (in RebornBuddy.exe) Version: 3.3.1; net-4.5.win32; release
Syntax
C#
[SerializableAttribute]
public class SortableList : IList, 
	ICollection, IEnumerable, ICloneable

The SortableList type exposes the following members.

Constructors
  NameDescription
Public methodSortableList
Default constructor. Since no IComparer is provided here, added objects must implement the IComparer interface.
Public methodSortableList(IComparer)
Constructor.
Public methodSortableList(Int32)
Constructor. Since no IComparer is provided, added objects must implement the IComparer interface.
Public methodSortableList(IComparer, Int32)
Constructor.
Top
Properties
  NameDescription
Public propertyAddDuplicates
If set to true, it will not be possible to add an object to the list if its value is already in the list.
Public propertyCapacity
Idem ArrayList
Public propertyCount
IList.ICollection implementation. Idem ArrayList
Public propertyIsFixedSize
IList implementation. Idem ArrayList
Public propertyIsReadOnly
IList implementation. Idem ArrayList
Public propertyIsSorted
'Get only' property that indicates if the list is sorted.
Public propertyIsSynchronized
IList.ICollection implementation. Idem ArrayList
Public propertyItem
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.
Public propertyKeepSorted
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
Public propertySyncRoot
IList.ICollection implementation. Idem ArrayList
Top
Methods
  NameDescription
Public methodAdd
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.
Public methodAddRange
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.
Public methodClear
IList implementation. Idem ArrayList
Public methodClone
ICloneable implementation. Idem ArrayList
Public methodContains
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.
Public methodCopyTo
IList.ICollection implementation. Idem ArrayList
Public methodEquals
Object.Equals() override.
(Overrides ObjectEquals(Object).)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetEnumerator
IList.IEnumerable implementation. Idem ArrayList
Public methodGetHashCode
Object.GetHashCode() override.
(Overrides ObjectGetHashCode.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIndexOf(Object)
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.
Public methodIndexOf(Object, SortableListEquality)
Idem IndexOf(object), but with a specified equality function
Public methodIndexOf(Object, Int32)
Idem IndexOf(object), but starting at a specified position in the list
Public methodIndexOf(Object, Int32, SortableListEquality)
Idem IndexOf(object), but with a start index and a specified equality function
Public methodIndexOfMax
Returns the object of the list whose value is maximum
Public methodIndexOfMin
Returns the object of the list whose value is minimum
Public methodInsert
IList implementation. Inserts an objects at a specified index. Cannot be used if the list has its KeepSorted property set to true.
Public methodInsertRange
Inserts a collection of objects at a specified index. Should not be used if the list is the KeepSorted property is set to true.
Public methodLimitNbOccurrences
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.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRemove
IList implementation. Idem ArrayList
Public methodRemoveAt
IList implementation. Idem ArrayList
Public methodRemoveDuplicates
Removes all duplicates in the list. Each value encountered will have only one representant.
Public methodSort
Sorts the elements in the list using ArrayList.Sort. Does nothing if the list is already sorted.
Public methodToString
Object.ToString() override. Build a string to represent the list.
(Overrides ObjectToString.)
Top
See Also