Class DictionarySet
IDictionary-based ICollection implementation that contains no duplicate elements.
Inherited Members
Namespace: Tangosol.Util.Collections
Assembly: Coherence.dll
Syntax
public class DictionarySet : ICollection, IEnumerable, ISerializable
Constructors
DictionarySet()
Default constructor. By default, HashDictionary is the underlying
Dictionary. If that is not the desired behavior, then pass an
explicit Dictionary to the DictionarySet
constructor. To
change the default Dictionary implementation, sub-class the
DictionarySet and override the
InstantiateDictionary()
method.
Declaration
public DictionarySet()
DictionarySet(ICollection)
Create and populate a new DictionarySet
with the given
collection of elements.
Declaration
public DictionarySet(ICollection items)
Parameters
Type | Name | Description |
---|---|---|
ICollection | items | The collection of elements to populate the set with. |
DictionarySet(IDictionary)
Create a new DictionarySet
that uses the specified IDictionary to
store its elements.
Declaration
protected DictionarySet(IDictionary dict)
Parameters
Type | Name | Description |
---|---|---|
IDictionary | dict | The storage dictionary. |
DictionarySet(SerializationInfo, StreamingContext)
Initializes a new instance of the DictionarySet
class using the
specified
SerializationInfo
and StreamingContext.
Declaration
protected DictionarySet(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
SerializationInfo | info | A SerializationInfo
object containing the information required to initialize this
|
StreamingContext | context | A StreamingContext object containing the source and destination of the serialized stream associated with this dictionary. |
Properties
Count
Gets the number of elements in this collection.
Declaration
public virtual int Count { get; }
Property Value
Type | Description |
---|---|
int | The number of elements in this collection. |
IsSynchronized
Gets a value indicating whether access to this collection is thread-safe.
Declaration
public virtual bool IsSynchronized { get; }
Property Value
Type | Description |
---|---|
bool | true if this collection is thread-safe; false otherwise. |
SyncRoot
Get an object that can be used to synchronize access to this collection.
Declaration
public virtual object SyncRoot { get; }
Property Value
Type | Description |
---|---|
object | An object that is used to synchronize access to this collection. |
Methods
Add(object)
Adds an element to the set and returns a value to indicate if the element was successfully added.
Declaration
public virtual bool Add(object item)
Parameters
Type | Name | Description |
---|---|---|
object | item | The element to add to the set. |
Returns
Type | Description |
---|---|
bool | true if the element is added to the set; false if the element is already in the set. |
Clear()
Remove all elements from the set.
Declaration
public virtual void Clear()
Contains(object)
Determine whether the set contains a specific element.
Declaration
public virtual bool Contains(object item)
Parameters
Type | Name | Description |
---|---|---|
object | item | The element to locate in the set. |
Returns
Type | Description |
---|---|
bool | true if the element is found in the set; false otherwise |
CopyTo(Array, int)
Copy elements from this collection into the one-dimensional array.
Declaration
public virtual void CopyTo(Array array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
Array | array | An array to which elements should be copied. |
int | arrayIndex | Index in |
Equals(object)
Determines whether the specified object is equal to this object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to this object; otherwise, false. |
Overrides
Equals(DictionarySet)
Compares this set with another set for equality.
Declaration
public virtual bool Equals(DictionarySet set)
Parameters
Type | Name | Description |
---|---|---|
DictionarySet | set | Set to compare this set with. |
Returns
Type | Description |
---|---|
bool |
|
Remarks
This method returns true if this set and the specified set have exactly the same contents.
GetEnumerator()
Return an IEnumerator that iterates through this collection.
Declaration
public virtual IEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator | An IEnumerator that iterates through this collection. |
GetHashCode()
Returns a hash code for this object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for this object. |
Overrides
GetObjectData(SerializationInfo, StreamingContext)
Populates SerializationInfo with the data needed to serialize this object.
Declaration
public void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
SerializationInfo | info | The SerializationInfo to populate with data. |
StreamingContext | context | The serialization context. |
Exceptions
Type | Condition |
---|---|
SecurityException | The caller does not have the required permission. |
InstantiateDictionary()
Factory pattern: Provide an underlying dictionary for this Set implementation.
Declaration
protected virtual IDictionary InstantiateDictionary()
Returns
Type | Description |
---|---|
IDictionary | A new dictionary instance. |
Remove(object)
Remove the specified element from the set.
Declaration
public virtual bool Remove(object item)
Parameters
Type | Name | Description |
---|---|---|
object | item | The element to remove from the set. |
Returns
Type | Description |
---|---|
bool | true if the element was successfully removed from the set; otherwise, false. This method also returns false if the specified element is not found in the set. |
ToString()
Returns string representation of this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | String representation of this instance. |