IGLib  1.5
The IGLib base library for development of numerical, technical and business applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
IG.Lib.SortedUniqueItemList< Type > Class Template Reference

Sorted list of unique items. It is guaranteed that at all times the list of containing items is sorted. More...

+ Inheritance diagram for IG.Lib.SortedUniqueItemList< Type >:
+ Collaboration diagram for IG.Lib.SortedUniqueItemList< Type >:

Public Member Functions

 SortedUniqueItemList ()
 Creates an empty sorted list of items with the default capacity. More...
 
 SortedUniqueItemList (int initialCapacity)
 Creates an empty sorted list of items with the specified initial capacity. More...
 
 SortedUniqueItemList (params Type[] items)
 Creates a sorted list of items containing all items from the specified table. More...
 
 SortedUniqueItemList (IList< Type > items)
 Creates a sorted list of items containing all items from the specified list. More...
 
 SortedUniqueItemList (ICollection< Type > items)
 Creates a sorted list of items containing all items from the specified collection. More...
 
Type[] ToArray ()
 Creates and returns an array that cotains elements of the current list, in the actual order. More...
 
void Clear ()
 Removes all elements from the current list. More...
 
bool Contains (Type item)
 Returns true if the current list contains the specified item, or false otherwise. More...
 
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. More...
 
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. More...
 
int Add (Type item)
 Adds the specified item to the list if it does not yet exist. NOT thread safe. More...
 
void RemoveChecked (Type item)
 Temoves the item from the list that is equal to the specified item. NOT thread safe. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
override string ToString ()
 Returns string representation of this sorted list. More...
 

Protected Member Functions

void Sort ()
 Sorts the internal list of items. NOT thread safe. More...
 

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. More...
 
Type this[int index] [get]
 Gets the specified element. More...
 
int Length [get]
 Gets the current number of elements in the list. More...
 
int Capacity [get, protected set]
 Gets the current number of elements in the list. More...
 
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). More...
 
bool PerformDownSizing [get, protected 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. More...
 
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. More...
 
- Properties inherited from IG.Lib.ILockable
object Lock [get]
 

Private Attributes

object _mainLock = new object()
 
List< Type > _list
 
int _capacityOverhead = 0
 
bool _performDownSizing = false
 
IComparer< Type > _comparer
 

Detailed Description

Sorted list of unique items. It is guaranteed that at all times the list of containing items is sorted.

Template Parameters
TypeType of items stored in the list.

$A Igor Dec08 Aug09;

Constructor & Destructor Documentation

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.

Parameters
initialCapacityInitial 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.

Parameters
itemsTable 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.

Parameters
itemsList 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.

Parameters
itemsCollection fo items that are added to the created list.

Member Function Documentation

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 ( )
inlineprotected

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.

Parameters
itemItem whose presence is checked.

Referenced by IG.Neural.NeuralTadej.ExampleCasting(), IG.Neural.NeuralTadej.ExampleQuadratic(), IG.Num.NeuralApproximatorBase.ExampleQuadratic(), and IG.Neural.NeuralTadej.ExampleStore().

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.

Parameters
itemItem that is searched for.
Returns
Index of the searched item on the list, if it is contained in the list. Otherwise, a negative number is returned that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of list length (number of elements). In this case, the bitwise compliment of the returned number can be used as index at which the item must be inserted in order to preseerve sorting of the list.

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.

Parameters
itemItem to be added to the list. For reference types, a reference is added.
Exceptions
ArgumentExceptionThrows 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.

Parameters
itemItem to be added to the list.
Returns
A non-negative index of the inserted item if the item was not contained in the list before the operation, and a negative number if the item already existed in the list.

Referenced by IG.Num.NeuralApproximatorBase.SetTrainingAndVerificationData().

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.

Parameters
itemItem to be removed.
Exceptions
InvalidOperationExceptionThrows 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.

Parameters
itemItem to be removed, found by comparision operations, takes into account that list is sorted.
Returns
Index of the removed item if the item existed in the list, or a negative number if the item was not found on the list.
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.

Parameters
itemsTable 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.

Parameters
itemsList 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.

Parameters
itemsCollection containg items to be added.
override string IG.Lib.SortedUniqueItemList< Type >.ToString ( )
inline

Returns string representation of this sorted list.

Returns

Member Data Documentation

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

Property Documentation

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.

Type IG.Lib.SortedUniqueItemList< Type >.this[int index]
get

Gets the specified element.

Parameters
indexIndex of the element.
int IG.Lib.SortedUniqueItemList< Type >.Length
get

Gets the current number of elements in the list.

Referenced by IG.Lib.IndexListDto.CopyFromPlain(), and IG.Num.SampledDataSet.ExtractFilteredData().

int IG.Lib.SortedUniqueItemList< Type >.Capacity
getprotected set

Gets the current number of elements in the list.

Setter is protected.

int IG.Lib.SortedUniqueItemList< Type >.CapacityOverhead
getset

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
getprotected 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
getset

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.


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