edu.northwestern.at.utils

## Class SingleTagTaggedStrings

- java.lang.Object
- - edu.northwestern.at.utils.SingleTagTaggedStrings

- All Implemented Interfaces:
    TaggedStrings

      public class SingleTagTaggedStrings
      extends java.lang.Object
      implements TaggedStrings

  A tagged strings implementation where all strings have the same tag value.

  Since all the strings have the same tag value, we use a sorted string array to hold the strings. We use binary search to locate the strings of interest. While using an array is slower than using a hash map (binary search = o(n*log(n)), hash = o(1)), the array saves lots of memory.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String[]` | `strings` Array of string values.
    `protected java.lang.String` | `tag` The common tag for all the string values.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SingleTagTaggedStrings(java.lang.String[] strings, java.lang.String tag)` Create SingleTagTaggedStrings object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `containsString(java.lang.String string)` See if specified string exists.
    `java.util.Set<java.lang.String>` | `getAllStrings()` Get set of all unique string values.
    `java.util.Set<java.lang.String>` | `getAllTags()` Get set of all unique tag values.
    `int` | `getStringCount()` Get number of strings.
    `java.lang.String` | `getTag(java.lang.String string)` Get the tag value associated with a string.
    `void` | `putTag(java.lang.String string, java.lang.String tag)` Set the tag value associated with a string.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### strings

          protected java.lang.String[] strings

      Array of string values.

    - #### tag

          protected java.lang.String tag

      The common tag for all the string values.

  - ### Constructor Detail

    - #### SingleTagTaggedStrings

          public SingleTagTaggedStrings(java.lang.String[] strings,
                                java.lang.String tag)

      Create SingleTagTaggedStrings object.
      Parameters:
        `strings` - String array of strings.
        `tag` - The common tag for all the strings.

  - ### Method Detail

    - #### containsString

          public boolean containsString(java.lang.String string)

      See if specified string exists.
      Specified by:
        `containsString` in interface `TaggedStrings`
      Parameters:
        `string` - The string.
      Returns:
        True if specified string exists.

    - #### getTag

          public java.lang.String getTag(java.lang.String string)

      Get the tag value associated with a string.
      Specified by:
        `getTag` in interface `TaggedStrings`
      Parameters:
        `string` - The string.
      Returns:
        The tag value associated with the string. May be null.

    - #### getStringCount

          public int getStringCount()

      Get number of strings.
      Specified by:
        `getStringCount` in interface `TaggedStrings`
      Returns:
        Number of strings.

    - #### getAllStrings

          public java.util.Set<java.lang.String> getAllStrings()

      Get set of all unique string values.
      Specified by:
        `getAllStrings` in interface `TaggedStrings`
      Returns:
        Set of all strings.

    - #### getAllTags

          public java.util.Set<java.lang.String> getAllTags()

      Get set of all unique tag values.
      Specified by:
        `getAllTags` in interface `TaggedStrings`
      Returns:
        Set of all unique tag values.

        The result always contains just one value, the common tag value associated with all the strings.

    - #### putTag

          public void putTag(java.lang.String string,
                    java.lang.String tag)

      Set the tag value associated with a string.
      Specified by:
        `putTag` in interface `TaggedStrings`
      Parameters:
        `string` - The string.
        `tag` - The tag.

        This is a no-op in this implementation.