Class CollectionWithoutDuplicatesBaseIList<T>
- Namespace
- SunamoCollectionWithoutDuplicates
- Assembly
- SunamoCollectionWithoutDuplicates.dll
Base class for collections that automatically prevent duplicate items and implement IList interface.
public abstract class CollectionWithoutDuplicatesBaseIList<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
TThe type of items in the collection.
- Inheritance
-
CollectionWithoutDuplicatesBaseIList<T>
- Implements
-
IList<T>ICollection<T>IEnumerable<T>
- Derived
- Inherited Members
- Extension Methods
Constructors
CollectionWithoutDuplicatesBaseIList()
Initializes a new instance of the collection without duplicates.
public CollectionWithoutDuplicatesBaseIList()
CollectionWithoutDuplicatesBaseIList(IList<T>)
Initializes a new instance of the collection without duplicates from an existing list.
public CollectionWithoutDuplicatesBaseIList(IList<T> list)
Parameters
listIList<T>The list to initialize from.
CollectionWithoutDuplicatesBaseIList(int)
Initializes a new instance of the collection without duplicates with a specified initial capacity.
public CollectionWithoutDuplicatesBaseIList(int initialCapacity)
Parameters
initialCapacityintThe initial capacity of the collection.
Properties
AllowNull
Gets or sets whether to allow null values and how to compare items. True = compare items by their string representation. False = compare items normally (not by string). Null = allow null values (cannot compare by string).
public bool? AllowNull { get; set; }
Property Value
- bool?
Collection
Gets or sets the underlying collection of items.
public List<T> Collection { get; set; }
Property Value
- List<T>
Count
Gets the number of items in the collection.
public int Count { get; }
Property Value
IsReadOnly
Gets a value indicating whether the collection is read-only.
public bool IsReadOnly { get; }
Property Value
this[int]
Gets or sets the item at the specified index.
public T this[int index] { get; set; }
Parameters
indexintThe zero-based index of the item to get or set.
Property Value
- T
The item at the specified index.
ResultOfBoolN
Previously Contains() returned bool? but must comply with IList which requires bool. This property stores the nullable bool result.
public bool? ResultOfBoolN { get; set; }
Property Value
- bool?
ShouldBreakOnConstruction
When true, breaks into debugger on construction. Used for debugging purposes.
public static bool ShouldBreakOnConstruction { get; set; }
Property Value
StringRepresentations
Gets or sets the string representations of items when comparing by string.
public List<string> StringRepresentations { get; set; }
Property Value
StringValue
The string value of the current item being processed.
protected string? StringValue { get; set; }
Property Value
Methods
Add(T)
Adds an item to the collection if it is not already present.
public void Add(T value)
Parameters
valueTThe item to add.
AddRange(IList<T>)
Adds multiple items to the collection, skipping duplicates.
public List<T> AddRange(IList<T> list)
Parameters
listIList<T>The list of items to add.
Returns
- List<T>
A list of items that were not added because they were duplicates.
AddWithIndex(T)
Adds an item to the collection and returns its index.
public abstract int AddWithIndex(T value)
Parameters
valueTThe item to add.
Returns
- int
The index of the item in the collection.
Clear()
Removes all items from the collection.
public void Clear()
Contains(T)
Determines whether the collection contains the specified item.
public bool Contains(T value)
Parameters
valueTThe item to check.
Returns
- bool
True if the item exists, false otherwise.
ContainsN(T)
Determines whether the collection contains the specified item.
public abstract bool? ContainsN(T value)
Parameters
valueTThe item to check.
Returns
- bool?
True if the item exists, false if not, null if the item is null and nulls are allowed.
CopyTo(T[], int)
Copies the items of the collection to an array, starting at a particular index.
public void CopyTo(T[] array, int arrayIndex)
Parameters
arrayT[]The destination array.
arrayIndexintThe zero-based index in the array at which copying begins.
DumpAsString(string, object)
This method is not supported and will throw an exception.
public string DumpAsString(string operation, object dumpAsStringHeaderArgs)
Parameters
Returns
- string
Never returns, always throws.
Exceptions
- Exception
Always thrown as this functionality has been moved to sunamo.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
An enumerator for the collection.
IndexOf(T)
Returns the index of the specified item in the collection.
public abstract int IndexOf(T value)
Parameters
valueTThe item to find.
Returns
- int
The zero-based index of the item.
Insert(int, T)
Inserts an item at the specified index.
public void Insert(int index, T value)
Parameters
indexintThe zero-based index at which to insert the item.
valueTThe item to insert.
IsComparingByString()
Determines whether the collection compares items by their string representation.
protected abstract bool IsComparingByString()
Returns
- bool
True if comparing by string, false otherwise.
Remove(T)
Removes the first occurrence of a specific item from the collection.
public bool Remove(T value)
Parameters
valueTThe item to remove.
Returns
- bool
True if the item was successfully removed, false otherwise.
RemoveAt(int)
Removes the item at the specified index.
public void RemoveAt(int index)
Parameters
indexintThe zero-based index of the item to remove.