Table of Contents

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

T

The type of items in the collection.

Inheritance
CollectionWithoutDuplicatesBaseIList<T>
Implements
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

list IList<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

initialCapacity int

The 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

int

IsReadOnly

Gets a value indicating whether the collection is read-only.

public bool IsReadOnly { get; }

Property Value

bool

this[int]

Gets or sets the item at the specified index.

public T this[int index] { get; set; }

Parameters

index int

The 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

bool

StringRepresentations

Gets or sets the string representations of items when comparing by string.

public List<string> StringRepresentations { get; set; }

Property Value

List<string>

StringValue

The string value of the current item being processed.

protected string? StringValue { get; set; }

Property Value

string

Methods

Add(T)

Adds an item to the collection if it is not already present.

public void Add(T value)

Parameters

value T

The item to add.

AddRange(IList<T>)

Adds multiple items to the collection, skipping duplicates.

public List<T> AddRange(IList<T> list)

Parameters

list IList<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

value T

The 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

value T

The 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

value T

The 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

array T[]

The destination array.

arrayIndex int

The 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

operation string

The operation name.

dumpAsStringHeaderArgs object

The dump arguments.

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

value T

The 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

index int

The zero-based index at which to insert the item.

value T

The 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

value T

The 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

index int

The zero-based index of the item to remove.