Class CharArraySet
A simple class that stores System.Strings as char[]'s in a hash table. Note that this is not a general purpose class. For example, it cannot remove items from the set, nor does it resize its hash table to be smaller, etc. It is designed to be quick to test if a char[] is in the set without the necessity of converting it to a System.String first.
You must specify the required Lucene.Net.Util.LuceneVersion compatibility when creating CharArraySet:
- As of 3.1, supplementary characters are properly lowercased.
Please note: This class implements System.Collections.Generic.ISet<T> but does not behave like it should in all cases. The generic type is System.String, because you can add any object to it, that has a string representation (which is converted to a string). The add methods will use System.Object.ToString() and store the result using a char[] buffer. The same behavior have the Contains(String) methods. The GetEnumerator() returns an IEnumerator{char[]}
Inheritance
Implements
Inherited Members
Namespace: Lucene.Net.Analysis.Util
Assembly: Lucene.Net.Analysis.Common.dll
Syntax
public class CharArraySet : ISet<string>, ICollection<string>, IEnumerable<string>, IEnumerable
Constructors
| Improve this Doc View SourceCharArraySet(LuceneVersion, ICollection<String>, Boolean)
Creates a set from a collection of objects.
Declaration
public CharArraySet(LuceneVersion matchVersion, ICollection<string> c, bool ignoreCase)
Parameters
| Type | Name | Description |
|---|---|---|
| Lucene.Net.Util.LuceneVersion | matchVersion | compatibility match version see CharArraySet for details. |
| System.Collections.Generic.ICollection<System.String> | c | a collection whose elements to be placed into the set |
| System.Boolean | ignoreCase |
|
CharArraySet(LuceneVersion, Int32, Boolean)
Create set with enough capacity to hold startSize terms
Declaration
public CharArraySet(LuceneVersion matchVersion, int startSize, bool ignoreCase)
Parameters
| Type | Name | Description |
|---|---|---|
| Lucene.Net.Util.LuceneVersion | matchVersion | compatibility match version see CharArraySet for details. |
| System.Int32 | startSize | the initial capacity |
| System.Boolean | ignoreCase |
|
Fields
| Improve this Doc View SourceEMPTY_SET
Declaration
public static readonly CharArraySet EMPTY_SET
Field Value
| Type | Description |
|---|---|
| CharArraySet |
Properties
| Improve this Doc View SourceCount
Gets the number of elements contained in the CharArraySet.
Declaration
public virtual int Count { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
IsReadOnly
true if the CharArraySet is read-only; otherwise false.
Declaration
public virtual bool IsReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
| Improve this Doc View SourceAdd(ICharSequence)
Add this J2N.Text.ICharSequence into the set
Declaration
public virtual bool Add(ICharSequence text)
Parameters
| Type | Name | Description |
|---|---|---|
| J2N.Text.ICharSequence | text |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Add(Char[])
Add this char[] directly to the set.
If ignoreCase is true for this CharArraySet, the text array will be directly modified.
The user should never modify this text array after calling this method.
Declaration
public virtual bool Add(char[] text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Char[] | text |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Add(Object)
Add the System.Object.ToString() representation of o into the set.
The System.Object.ToString() method is called after setting the thread to System.Globalization.CultureInfo.InvariantCulture.
If the type of o is a value type, it will be converted using the
System.Globalization.CultureInfo.InvariantCulture.
Declaration
public virtual bool Add(object o)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | o | A string-able object |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Add(String)
Add this System.String into the set
Declaration
public virtual bool Add(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Clear()
Clears all entries in this set. This method is supported for reusing, but not ICollection{string}.Remove(string).
Declaration
public virtual void Clear()
Contains(ICharSequence)
true if the J2N.Text.ICharSequence is in the set
Declaration
public virtual bool Contains(ICharSequence cs)
Parameters
| Type | Name | Description |
|---|---|---|
| J2N.Text.ICharSequence | cs |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Contains(Char[])
true if the char[]s
are in the set
Declaration
public virtual bool Contains(char[] text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Char[] | text |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Contains(Char[], Int32, Int32)
true if the length chars of text starting at offset
are in the set
Declaration
public virtual bool Contains(char[] text, int offset, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Char[] | text | |
| System.Int32 | offset | |
| System.Int32 | length |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Contains(Object)
true if the System.Object.ToString() representation of o is in the set
Declaration
public virtual bool Contains(object o)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | o |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Contains(String)
true if the System.String is in the set
Declaration
public virtual bool Contains(string cs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cs |
Returns
| Type | Description |
|---|---|
| System.Boolean |
ContainsAll(IEnumerable<String>)
Returns true if this collection contains all of the elements
in the specified collection.
Declaration
public virtual bool ContainsAll(IEnumerable<string> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.String> | other | collection to be checked for containment in this collection |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
ContainsAll<T>(IEnumerable<T>)
Returns true if this collection contains all of the elements
in the specified collection.
Declaration
public virtual bool ContainsAll<T>(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | collection to be checked for containment in this collection |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| T |
Copy<T>(LuceneVersion, ICollection<T>)
Returns a copy of the given set as a CharArraySet. If the given set is a CharArraySet the ignoreCase property will be preserved.
Note: If you intend to create a copy of another CharArraySet where the Lucene.Net.Util.LuceneVersion of the source set differs from its copy CharArraySet(LuceneVersion, ICollection<String>, Boolean) should be used instead. The Copy<T>(LuceneVersion, ICollection<T>) will preserve the Lucene.Net.Util.LuceneVersion of the source set it is an instance of CharArraySet.
Declaration
public static CharArraySet Copy<T>(LuceneVersion matchVersion, ICollection<T> set)
Parameters
| Type | Name | Description |
|---|---|---|
| Lucene.Net.Util.LuceneVersion | matchVersion | compatibility match version. This argument will be ignored if the given set is a CharArraySet. |
| System.Collections.Generic.ICollection<T> | set | a set to copy |
Returns
| Type | Description |
|---|---|
| CharArraySet | a copy of the given set as a CharArraySet. If the given set is a CharArraySet the Lucene.Net.Analysis.Util.CharArrayMap`1.ignoreCase field as well as the MatchVersion will be preserved. |
Type Parameters
| Name | Description |
|---|---|
| T |
CopyTo(String[], Int32)
Copies the entire CharArraySet to a one-dimensional string[] array, starting at the specified index of the target array.
Declaration
public void CopyTo(string[] array, int arrayIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String[] | array | The one-dimensional string[] Array that is the destination of the elements copied from CharArraySet. The Array must have zero-based indexing. |
| System.Int32 | arrayIndex | The zero-based index in array at which copying begins. |
Equals(Object)
Compares the specified object with this set for equality. Returns true if the
given object is also a set, the two sets have the same size, and every member of the
given set is contained in this set. This ensures that the equals method works properly
across different implementations of the ISet{string} interface.
This implementation first checks if the specified object is this set; if so it
returns true. Then, it checks if the specified object is a set whose
size is identical to the size of this set; if not, it returns false. If so,
it uses the enumerator of this set and the specified object to determine if all of the
contained values are present (using System.String.Equals(System.String)).
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | object to be compared for equality with this set |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Overrides
GetEnumerator()
Returns an System.Collections.IEnumerator for char[] instances in this set.
Declaration
public virtual IEnumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.IEnumerator |
GetHashCode()
Returns the hash code value for this set. The hash code of a set
is defined to be the sum of the hash codes of the elements in the
set, where the hash code of a null element is defined to be zero.
This ensures that s1.Equals(s2) implies that
s1.GetHashCode()==s2.GetHashCode() for any two sets s1 and s2.
This implementation iterates over the set, calling the GetHashCode()
method on each element in the set, and adding up the results.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | the hash code value for this set |
Overrides
IsProperSubsetOf(IEnumerable<String>)
Determines whether a CharArraySet object is a proper subset of the specified collection.
Declaration
public virtual bool IsProperSubsetOf(IEnumerable<string> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.String> | other | The collection to compare to the current CharArraySet object. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
IsProperSubsetOf<T>(IEnumerable<T>)
Determines whether a CharArraySet object is a proper subset of the specified collection.
Declaration
public virtual bool IsProperSubsetOf<T>(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current CharArraySet object. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| T |
IsProperSupersetOf(IEnumerable<String>)
Determines whether a CharArraySet object is a proper superset of the specified collection.
Declaration
public virtual bool IsProperSupersetOf(IEnumerable<string> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.String> | other | The collection to compare to the current CharArraySet object. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
IsProperSupersetOf<T>(IEnumerable<T>)
Determines whether a CharArraySet object is a proper superset of the specified collection.
Declaration
public virtual bool IsProperSupersetOf<T>(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current CharArraySet object. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| T |
IsSubsetOf(IEnumerable<String>)
Determines whether a CharArraySet object is a subset of the specified collection.
Declaration
public virtual bool IsSubsetOf(IEnumerable<string> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.String> | other | The collection to compare to the current CharArraySet object. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
IsSubsetOf<T>(IEnumerable<T>)
Determines whether a CharArraySet object is a subset of the specified collection.
Declaration
public virtual bool IsSubsetOf<T>(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current CharArraySet object. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| T |
IsSupersetOf(IEnumerable<String>)
Determines whether a CharArraySet object is a superset of the specified collection.
Declaration
public virtual bool IsSupersetOf(IEnumerable<string> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.String> | other | The collection to compare to the current CharArraySet object. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
IsSupersetOf<T>(IEnumerable<T>)
Determines whether a CharArraySet object is a superset of the specified collection.
Declaration
public virtual bool IsSupersetOf<T>(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current CharArraySet object. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| T |
Overlaps(IEnumerable<String>)
Determines whether the current CharArraySet object and a specified collection share common elements.
Declaration
public virtual bool Overlaps(IEnumerable<string> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.String> | other | The collection to compare to the current CharArraySet object. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Overlaps<T>(IEnumerable<T>)
Determines whether the current CharArraySet object and a specified collection share common elements.
Declaration
public virtual bool Overlaps<T>(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current CharArraySet object. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| T |
SetEquals(IEnumerable<String>)
Determines whether the current set and the specified collection contain the same elements.
Declaration
public virtual bool SetEquals(IEnumerable<string> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.String> | other | The collection to compare to the current set. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
ToString()
Returns a string that represents the current object. (Inherited from System.Object.)
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String |
Overrides
UnionWith(IEnumerable<ICharSequence>)
Modifies the current CharArraySet to contain all elements that are present in itself, the specified collection, or both.
Declaration
public virtual bool UnionWith(IEnumerable<ICharSequence> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<J2N.Text.ICharSequence> | other | The collection whose elements should be merged into the CharArraySet. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
UnionWith(IEnumerable<Char[]>)
Modifies the current CharArraySet to contain all elements that are present in itself, the specified collection, or both.
Declaration
public virtual bool UnionWith(IEnumerable<char[]> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Char[]> | other | The collection whose elements should be merged into the CharArraySet. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
UnionWith(IEnumerable<String>)
Modifies the current CharArraySet to contain all elements that are present in itself, the specified collection, or both.
Declaration
public virtual void UnionWith(IEnumerable<string> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.String> | other | The collection whose elements should be merged into the CharArraySet. |
UnionWith<T>(IEnumerable<T>)
Modifies the current CharArraySet to contain all elements that are present in itself, the specified collection, or both.
Declaration
public virtual bool UnionWith<T>(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | other | The collection whose elements should be merged into the CharArraySet. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| T |
UnmodifiableSet(CharArraySet)
Returns an unmodifiable CharArraySet. This allows to provide unmodifiable views of internal sets for "read-only" use.
Declaration
public static CharArraySet UnmodifiableSet(CharArraySet set)
Parameters
| Type | Name | Description |
|---|---|---|
| CharArraySet | set | a set for which the unmodifiable set is returned. |
Returns
| Type | Description |
|---|---|
| CharArraySet | an new unmodifiable CharArraySet. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | if the given set is |
Explicit Interface Implementations
| Improve this Doc View SourceICollection<String>.Add(String)
LUCENENET specific for supporting System.Collections.Generic.ICollection<T>.
Declaration
void ICollection<string>.Add(string item)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | item |
IEnumerable<String>.GetEnumerator()
Declaration
IEnumerator<string> IEnumerable<string>.GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerator<System.String> |