IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.
|
Sorted list of unique items. It is guaranteed that at all times the list of containing items is sorted. More...
Public Member Functions | |
SortedUniqueItemList () | |
Creates an empty sorted list of items with the default capacity. | |
SortedUniqueItemList (int initialCapacity) | |
Creates an empty sorted list of items with the specified initial capacity. | |
SortedUniqueItemList (params Type[] items) | |
Creates a sorted list of items containing all items from the specified table. | |
SortedUniqueItemList (IList< Type > items) | |
Creates a sorted list of items containing all items from the specified list. | |
SortedUniqueItemList (ICollection< Type > items) | |
Creates a sorted list of items containing all items from the specified collection. | |
Type[] | ToArray () |
Creates and returns an array that cotains elements of the current list, in the actual order. | |
void | Clear () |
Removes all elements from the current list. | |
bool | Contains (Type item) |
Returns true if the current list contains the specified item, or false otherwise. | |
int | IndexOf (Type item) |
Returns index of the specified item on the list, if it exists, otherwise a negative number is returned. NOT thread safe. | |
void | AddChecked (Type item) |
Adds the specified element to the list if it is not yet contained in it. If the item is already contained in the list then an exception is thrown. NOT thread safe. | |
int | Add (Type item) |
Adds the specified item to the list if it does not yet exist. NOT thread safe. | |
void | RemoveChecked (Type item) |
Temoves the item from the list that is equal to the specified item. NOT thread safe. | |
int | Remove (Type item) |
Removes the specified item from the list if it exists. NOT thread safe. The object is locked when operation is performed. | |
void | Add (Type[] items) |
Adds the specified table of items to the current list. Items are added one by one, which is not the most efficient. The object is locked when operation is performed. | |
void | Add (IList< Type > items) |
Adds the specified list of items to the current list. Items are added one by one, which is not the most efficient. | |
void | Add (ICollection< Type > items) |
Adds the specified collection of items to the current list. Items are added one by one, which is not the most efficient. The object is locked when operation is performed. | |
override string | ToString () |
Returns string representation of this sorted list. | |
Protected Member Functions | |
void | Sort () |
Sorts the internal list of items. NOT thread safe. | |
Properties | |
object | Lock [get] |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock. | |
Type | this [int index] [get] |
Gets the specified element. | |
int | Length [get] |
Gets the current number of elements in the list. | |
int | Capacity [get, set] |
Gets the current number of elements in the list. | |
int | CapacityOverhead [get, set] |
Overhead in capacity. If differnt than 0 then when current capacity is filled, adding operations will perform resizing in such a way that this number of elements are unoccupied. In this way, the frequency of resizes is reduced. Also, removing operations can perform downsizing if the number of free elements after removal is greater than CapacityOverhead (dependent on value of the PerformDownSizing flag). | |
bool | PerformDownSizing [get, set] |
Flag specifying whether capacity can be reduced on removal operations which would generate large excess of list capacity with respect to the number of actual elements contained in the list. | |
IComparer< Type > | Comparer [get, set] |
Gets or sets the comparer. If a new comparer is set then re-sorting of the list is performed. Setter is thread safe, but getter is not. | |
Private Attributes | |
object | _mainLock = new object() |
List< Type > | _list |
int | _capacityOverhead = 0 |
bool | _performDownSizing = false |
IComparer< Type > | _comparer |
Sorted list of unique items. It is guaranteed that at all times the list of containing items is sorted.
Type | Type of items stored in the list. |
$A Igor Dec08 Aug09;
IG::Lib::SortedUniqueItemList< Type >::SortedUniqueItemList | ( | ) | [inline] |
Creates an empty sorted list of items with the default capacity.
IG::Lib::SortedUniqueItemList< Type >::SortedUniqueItemList | ( | int | initialCapacity | ) | [inline] |
Creates an empty sorted list of items with the specified initial capacity.
initialCapacity | Initial capacity of the list. |
IG::Lib::SortedUniqueItemList< Type >::SortedUniqueItemList | ( | params Type[] | items | ) | [inline] |
Creates a sorted list of items containing all items from the specified table.
items | Table fo items that are added to the created list. |
IG::Lib::SortedUniqueItemList< Type >::SortedUniqueItemList | ( | IList< Type > | items | ) | [inline] |
Creates a sorted list of items containing all items from the specified list.
items | List fo items that are added to the created list. |
IG::Lib::SortedUniqueItemList< Type >::SortedUniqueItemList | ( | ICollection< Type > | items | ) | [inline] |
Creates a sorted list of items containing all items from the specified collection.
items | Collection fo items that are added to the created list. |
Type [] IG::Lib::SortedUniqueItemList< Type >::ToArray | ( | ) | [inline] |
Creates and returns an array that cotains elements of the current list, in the actual order.
void IG::Lib::SortedUniqueItemList< Type >::Clear | ( | ) | [inline] |
Removes all elements from the current list.
void IG::Lib::SortedUniqueItemList< Type >::Sort | ( | ) | [inline, protected] |
Sorts the internal list of items. NOT thread safe.
bool IG::Lib::SortedUniqueItemList< Type >::Contains | ( | Type | item | ) | [inline] |
Returns true if the current list contains the specified item, or false otherwise.
item | Item whose presence is checked. |
int IG::Lib::SortedUniqueItemList< Type >::IndexOf | ( | Type | item | ) | [inline] |
Returns index of the specified item on the list, if it exists, otherwise a negative number is returned. NOT thread safe.
item | Item that is searched for. |
When the returned value is negative (the item is not contained in the list), then its negative value can be directly used to predict on which place the specified item would be inserted in the list.
void IG::Lib::SortedUniqueItemList< Type >::AddChecked | ( | Type | item | ) | [inline] |
Adds the specified element to the list if it is not yet contained in it. If the item is already contained in the list then an exception is thrown. NOT thread safe.
item | Item to be added to the list. For reference types, a reference is added. |
ArgumentException | Throws when an item equal to the specified item (according to the specified comparison operator) already exists on the list. |
Use the Add() method for safe addition (does not throw an exception if the specified item is already contained in the list).
int IG::Lib::SortedUniqueItemList< Type >::Add | ( | Type | item | ) | [inline] |
Adds the specified item to the list if it does not yet exist. NOT thread safe.
item | Item to be added to the list. |
void IG::Lib::SortedUniqueItemList< Type >::RemoveChecked | ( | Type | item | ) | [inline] |
Temoves the item from the list that is equal to the specified item. NOT thread safe.
item | Item to be removed. |
InvalidOperationException | Throws when the specified item to be removed does not exist on the list. |
Use the Remove() method for safe removal (does not throw exception ehen the specified item does not exist).
int IG::Lib::SortedUniqueItemList< Type >::Remove | ( | Type | item | ) | [inline] |
Removes the specified item from the list if it exists. NOT thread safe. The object is locked when operation is performed.
item | Item to be removed, found by comparision operations, takes into account that list is sorted. |
void IG::Lib::SortedUniqueItemList< Type >::Add | ( | Type[] | items | ) | [inline] |
Adds the specified table of items to the current list. Items are added one by one, which is not the most efficient. The object is locked when operation is performed.
items | Table containg items to be added. |
void IG::Lib::SortedUniqueItemList< Type >::Add | ( | IList< Type > | items | ) | [inline] |
Adds the specified list of items to the current list. Items are added one by one, which is not the most efficient.
items | List containg items to be added. |
void IG::Lib::SortedUniqueItemList< Type >::Add | ( | ICollection< Type > | items | ) | [inline] |
Adds the specified collection of items to the current list. Items are added one by one, which is not the most efficient. The object is locked when operation is performed.
items | Collection containg items to be added. |
override string IG::Lib::SortedUniqueItemList< Type >::ToString | ( | ) | [inline] |
Returns string representation of this sorted list.
object IG::Lib::SortedUniqueItemList< Type >::_mainLock = new object() [private] |
List<Type> IG::Lib::SortedUniqueItemList< Type >::_list [private] |
int IG::Lib::SortedUniqueItemList< Type >::_capacityOverhead = 0 [private] |
bool IG::Lib::SortedUniqueItemList< Type >::_performDownSizing = false [private] |
IComparer<Type> IG::Lib::SortedUniqueItemList< Type >::_comparer [private] |
object IG::Lib::SortedUniqueItemList< Type >::Lock [get] |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.
Implements IG::Lib::ILockable.
Type IG::Lib::SortedUniqueItemList< Type >::this[int index] [get] |
Gets the specified element.
index | Index of the element. |
int IG::Lib::SortedUniqueItemList< Type >::Length [get] |
Gets the current number of elements in the list.
int IG::Lib::SortedUniqueItemList< Type >::Capacity [get, set] |
Gets the current number of elements in the list.
Setter is protected.
int IG::Lib::SortedUniqueItemList< Type >::CapacityOverhead [get, set] |
Overhead in capacity. If differnt than 0 then when current capacity is filled, adding operations will perform resizing in such a way that this number of elements are unoccupied. In this way, the frequency of resizes is reduced. Also, removing operations can perform downsizing if the number of free elements after removal is greater than CapacityOverhead (dependent on value of the PerformDownSizing flag).
bool IG::Lib::SortedUniqueItemList< Type >::PerformDownSizing [get, set] |
Flag specifying whether capacity can be reduced on removal operations which would generate large excess of list capacity with respect to the number of actual elements contained in the list.
If the flag is true then downsizing will occur when the capacity exceeds number of items by twice the CapacityOverhead. Downsizing does not Occur if CapacityOverhead is 0.
IComparer<Type> IG::Lib::SortedUniqueItemList< Type >::Comparer [get, set] |
Gets or sets the comparer. If a new comparer is set then re-sorting of the list is performed. Setter is thread safe, but getter is not.