# StringHashTrie

`com.jsmacrosce.StringHashTrie`

Stores strings in a prefix trie and provides collection operations and prefix searches.

## Constructors

### new StringHashTrie {#com.jsmacrosce.StringHashTrie_constructor-}

```js
new StringHashTrie()
```

Initializes an empty root trie with no parent.

## Methods

### add {#com.jsmacrosce.StringHashTrie_add-String-}

```js
add(String s): boolean
```

Adds a case-sensitive string if it is not already stored. A null string causes [NullPointerException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html).

**Parameters:**
- `s`: string to add

**Returns:** `true` if the string was added; `false` if it was already present

### addAll {#com.jsmacrosce.StringHashTrie_addAll-Collection-}

```js
addAll(Collection<? extends String> c): boolean
```

Adds each string in the collection. Processing is not rolled back if an element fails; a null collection or null element causes [NullPointerException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html).

**Parameters:**
- `c`: strings to add

**Returns:** `true` if at least one string was added

### addAll {#com.jsmacrosce.StringHashTrie_addAll-String[]-}

```js
addAll(String... o): boolean
```

Adds each supplied string. Processing is not rolled back if an element fails; a null array or null element causes [NullPointerException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html).

**Parameters:**
- `o`: strings to add

**Returns:** `true` if at least one string was added

### clear {#com.jsmacrosce.StringHashTrie_clear-}

```js
clear(): void
```

Removes all strings stored directly or below this trie node.

### contains {#com.jsmacrosce.StringHashTrie_contains-Object-}

```js
contains(Object o): boolean
```

Tests whether this trie contains the supplied string, using case-sensitive matching.  
 Non-string values, including `null`, are not contained.

**Parameters:**
- `o`: value to test

**Returns:** `true` if `o` is a stored string

### containsAll {#com.jsmacrosce.StringHashTrie_containsAll-Collection-}

```js
containsAll(Collection<?> c): boolean
```

Tests whether every element of the collection is a stored string. Non-strings and `null` elements are not contained; a null collection causes [NullPointerException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html).

**Parameters:**
- `c`: collection of values to test

**Returns:** `true` if every element is contained, including when the collection is empty

### containsAll {#com.jsmacrosce.StringHashTrie_containsAll-String[]-}

```js
containsAll(String... o): boolean
```

Tests whether every supplied string is stored; unlike the collection overload, this accepts an array of strings.  
 Null elements are not contained; a null array causes [NullPointerException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html).

**Parameters:**
- `o`: strings to test

**Returns:** `true` if every string is contained, including when the array is empty

### getAll {#com.jsmacrosce.StringHashTrie_getAll-}

```js
getAll(): Set<String>
```

Returns a snapshot of the strings in this trie; modifying the set does not modify the trie.

**Returns:** all strings

### getAllWithPrefix {#com.jsmacrosce.StringHashTrie_getAllWithPrefix-String-}

```js
getAllWithPrefix(String prefix): Set<String>
```

Searches for strings beginning with the given case-sensitive prefix. When the prefix ends within a trie key,  
this returns the first matching leaf if present; otherwise, it returns the first matching child subtree, so
other matches may be omitted.

**Parameters:**
- `prefix`: prefix to match

**Returns:** matching strings, or all strings when `prefix` is empty

### getAllWithPrefixCaseInsensitive {#com.jsmacrosce.StringHashTrie_getAllWithPrefixCaseInsensitive-String-}

```js
getAllWithPrefixCaseInsensitive(String prefix): Set<String>
```

Searches for strings beginning with the given prefix, ignoring case. When the prefix is longer than a trie key,  
matching is performed segment by segment, which may omit matches when case-insensitive comparison changes length.

**Parameters:**
- `prefix`: prefix to match

**Returns:** matching strings, or all strings when `prefix` is empty

### isEmpty {#com.jsmacrosce.StringHashTrie_isEmpty-}

```js
isEmpty(): boolean
```

Returns whether this node has no directly stored strings and no children.

**Returns:** `true` when this node has neither leaves nor children

### iterator {#com.jsmacrosce.StringHashTrie_iterator-}

```js
iterator(): Iterator<String>
```

Returns an iterator over a snapshot of the strings currently stored in this trie. Its order is unspecified;  
 removing through the iterator affects only the snapshot, and later trie changes are not reflected.

**Returns:** an iterator over the snapshot

### remove {#com.jsmacrosce.StringHashTrie_remove-Object-}

```js
remove(Object o): boolean
```

Removes a string from this trie if present.

**Parameters:**
- `o`: string to remove

**Returns:** `true` if the string was present and removed

### removeAll {#com.jsmacrosce.StringHashTrie_removeAll-Collection-}

```js
removeAll(Collection<?> c): boolean
```

Removes each supplied element that is a string in this trie. The collection must not be `null`; otherwise this method throws `NullPointerException`.

**Parameters:**
- `c`: non-null collection of elements to remove; non-strings and null elements are ignored

**Returns:** `true` if at least one string was removed

### removeAll {#com.jsmacrosce.StringHashTrie_removeAll-String[]-}

```js
removeAll(String... o): boolean
```

Removes each supplied string from this trie. The array must not be `null`; otherwise this method throws `NullPointerException`.

**Parameters:**
- `o`: non-null array of strings to remove

**Returns:** `true` if at least one string was removed

### retainAll {#com.jsmacrosce.StringHashTrie_retainAll-Collection-}

```js
retainAll(Collection<?> c): boolean
```

Removes every stored string not contained in the supplied collection. The collection must not be `null`; otherwise this method throws `NullPointerException`.

**Parameters:**
- `c`: non-null collection of strings to retain

**Returns:** `true` if at least one string was removed

### retainAll {#com.jsmacrosce.StringHashTrie_retainAll-String[]-}

```js
retainAll(String... o): boolean
```

Removes every stored string not present in the supplied strings. The array must not be `null`; otherwise this method throws `NullPointerException`.

**Parameters:**
- `o`: non-null array of strings to retain

**Returns:** `true` if at least one string was removed

### size {#com.jsmacrosce.StringHashTrie_size-}

```js
size(): int
```

Returns the number of strings stored in this trie, including strings in descendant nodes.

**Returns:** the total stored string count

### toArray {#com.jsmacrosce.StringHashTrie_toArray-}

```js
toArray(): String[]
```

Returns the strings currently stored in this trie as a new array; its order is unspecified.

**Returns:** a new array containing the current strings

### toArray {#com.jsmacrosce.StringHashTrie_toArray-T[]-}

```js
toArray(T[] a): T[]
```

Copies the strings currently stored in this trie into an array, following `Set.toArray(T[])` semantics.  
 The result is a snapshot with unspecified element order. If `a` is too small, a new array of the same runtime
 type is returned; if it is larger, the first unused element is set to `null`. A null array causes
 `NullPointerException`, and an incompatible component type causes `ArrayStoreException`.

**Parameters:**
- `a`: destination array

**Type Parameters:**
- `T`: the array element type

**Returns:** the destination array if large enough, otherwise a new array of the same runtime type

### toArray {#com.jsmacrosce.StringHashTrie_toArray-IntFunction-}

```js
toArray(IntFunction<T[]> arg0): T[]
```

**Returns:** `T[]`

### toString {#com.jsmacrosce.StringHashTrie_toString-}

```js
toString(): String
```

**Returns:** a structural representation for debugging; it may not be valid JSON
