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: 840 $
Author:
posenato
See Also:
  • Field Details

    • ALETTER

      public static final String ALETTER
      A-Letter.
      See Also:
    • ALETTER_RANGE

      public static final String ALETTER_RANGE
      A-Letter 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 not found name.
      See Also:
    • MAX_ALABELALPHABET_SIZE

      public static final byte MAX_ALABELALPHABET_SIZE
      Maximum size for the alphabet. Such limitation is dictated by the ALabel class implementation.
      See Also:
    • serialVersionUID

      static final long serialVersionUID
      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 a-letter
      Returns:
      the a-letter associated to index k, DEFAULT_ALETTER_RET_VALUE if it does not exist
    • index

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

      public boolean isEmpty()
      Returns:
      true is this does not contain a-letter
    • put

      public byte put(ALabelAlphabet.ALetter v)
      Puts the element v in the map if not present.
      Parameters:
      v - a non-null a-letter
      Returns:
      the index associate to 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