CharArraySet

A simple class that stores 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 String first.

Please note: This class implements java.util.Set but does not behave like it should in all cases. The generic type is Set<Object>, because you can add any object to it, that has a string representation. The add methods will use Object.toString and store the result using a char[] buffer. The same behavior have the contains() methods. The .iterator returns an Iterator<char[]>.

Constructors

Link copied to clipboard
constructor(startSize: Int, ignoreCase: Boolean)

Create set with enough capacity to hold startSize terms

constructor(c: MutableCollection<Any>, ignoreCase: Boolean)

Creates a set from a Collection of objects.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val size: Int

Functions

Link copied to clipboard
open override fun add(o: Any): Boolean

open fun add(text: CharArray): Boolean

Add this char[] directly to the set. If ignoreCase is true for this Set, the text array will be directly modified. The user should never modify this text array after calling this method.

open fun add(text: CharSequence): Boolean

Add this CharSequence into the set

open fun add(text: String): Boolean

Add this String into the set

Link copied to clipboard
open override fun addAll(elements: Collection<Any>): Boolean
Link copied to clipboard
open override fun clear()

Clears all entries in this set. This method is supported for reusing, but not Set.remove.

Link copied to clipboard
open operator override fun contains(o: Any): Boolean

true if the CharSequence is in the set

fun contains(text: CharArray, off: Int, len: Int): Boolean

true if the len chars of text starting at off are in the set

Link copied to clipboard
open override fun containsAll(elements: Collection<Any>): Boolean
Link copied to clipboard
expect open override fun isEmpty(): Boolean
Link copied to clipboard
open operator override fun iterator(): MutableIterator<Any>

Returns an Iterator for char[] instances in this set.

Link copied to clipboard
open override fun remove(element: Any): Boolean
Link copied to clipboard
open override fun removeAll(elements: Collection<Any>): Boolean
Link copied to clipboard
open override fun retainAll(elements: Collection<Any>): Boolean
Link copied to clipboard
open override fun toString(): String