Class ALabelAlphabet

java.lang.Object
it.univr.di.labeledvalue.ALabelAlphabet
All Implemented Interfaces:
Serializable

public class ALabelAlphabet extends Object implements Serializable
A customizable alphabet, where elements are strings. Each element has an index (integer) that can be used to retrieve the element.

On 2017-4-13, it turns out that an A-Label, introduced in the first articles, is not just a name of a node representing an upper-case letter (as used in Morris's rules), but it must be a set of upper-case letters.

Moreover, such upper-case letters represent node names and, therefore, they should be strings instead of letters.

To limit the memory footprint and to speed up some computation, class ALabel uses an alphabet, ALabelAlphabet, for building labels. ALabelAlphabet associate each node name with one ALabelAlphabet.ALetter univocally. Each ALabelAlphabet.ALetter has a codepoint (position) in the alphabet. Limiting to 32 the possible ALetters, one ALabel can be represented by just an int.

Version:
$Rev: 993 $
Author:
posenato
See Also:
  • Field Details

    • ALETTER

      public static final String ALETTER
      ALetter.
      See Also:
    • ALETTER_RANGE

      public static final String ALETTER_RANGE
      ALetter range.
      See Also:
    • DEFAULT_ALETTER_RET_VALUE

      public static final ALabelAlphabet.ALetter DEFAULT_ALETTER_RET_VALUE
      Default value for not found index.
    • DEFAULT_BYTE_RET_VALUE

      public static final byte DEFAULT_BYTE_RET_VALUE
      Default value for a not-found name.
      See Also:
    • MAX_ALABELALPHABET_SIZE

      public static final byte MAX_ALABELALPHABET_SIZE
      Maximum size for the alphabet. The ALabel class implementation dictates such a limitation.
      See Also:
    • serialVersionUID

      static final long serialVersionUID
      Serial number
      See Also:
  • Constructor Details

    • ALabelAlphabet

      public ALabelAlphabet(ALabelAlphabet alpha)
      Constructor by copy. The new alphabet is an independent copy.
      Parameters:
      alpha - alphabet to copy.
    • ALabelAlphabet

      public ALabelAlphabet(int size1)
      Parameters:
      size1 - initial size of alphabet
    • ALabelAlphabet

      public ALabelAlphabet()
      Default constructor.
  • Method Details

    • clear

      public void clear()
      Cleans the map.
    • containsValue

      public boolean containsValue(ALabelAlphabet.ALetter v)
      Parameters:
      v - the input letter
      Returns:
      true if v is present, false otherwise
    • get

      public ALabelAlphabet.ALetter get(byte k)
      Parameters:
      k - the index of the wanted ALetter
      Returns:
      the ALetter associated with index k, DEFAULT_ALETTER_RET_VALUE if it does not exist.
    • index

      public byte index(ALabelAlphabet.ALetter name)
      Parameters:
      name - the input ALetter
      Returns:
      the index associated with name if it exists, DEFAULT_BYTE_RET_VALUE otherwise.
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if this does not contain any ALetter.
    • put

      public byte put(ALabelAlphabet.ALetter v)
      Puts the element v in the map if not present.
      Parameters:
      v - a non-null ALetter
      Returns:
      the index associate with the element v if v is present, 0xff if v is null.
      Throws:
      IllegalArgumentException - if there are already MAX_ALABELALPHABET_SIZE elements in the map
    • size

      public int size()
      Returns:
      the current size of this alphabet
    • toString

      public String toString()
      Overrides:
      toString in class Object