Package it.univr.di.labeledvalue
Class ALabelAlphabet
java.lang.Object
it.univr.di.labeledvalue.ALabelAlphabet
- All Implemented Interfaces:
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classALetter makes it simpler to check if a node name is appropriate. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringALetter.static final StringALetter range.static final ALabelAlphabet.ALetterDefault value for not found index.static final byteDefault value for a not-found name.static final byteMaximum size for the alphabet.(package private) static final longSerial number -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ALabelAlphabet(int size1) ALabelAlphabet(ALabelAlphabet alpha) Constructor by copy. -
Method Summary
-
Field Details
-
ALETTER
ALetter.- See Also:
-
ALETTER_RANGE
ALetter range.- See Also:
-
DEFAULT_ALETTER_RET_VALUE
Default value for not found index. -
DEFAULT_BYTE_RET_VALUE
public static final byte DEFAULT_BYTE_RET_VALUEDefault value for a not-found name.- See Also:
-
MAX_ALABELALPHABET_SIZE
public static final byte MAX_ALABELALPHABET_SIZEMaximum size for the alphabet. The ALabel class implementation dictates such a limitation.- See Also:
-
serialVersionUID
static final long serialVersionUIDSerial number- See Also:
-
-
Constructor Details
-
ALabelAlphabet
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
- Parameters:
v- the input letter- Returns:
- true if v is present, false otherwise
-
get
- Parameters:
k- the index of the wanted ALetter- Returns:
- the ALetter associated with index k,
DEFAULT_ALETTER_RET_VALUEif it does not exist.
-
index
- Parameters:
name- the input ALetter- Returns:
- the index associated with name if it exists,
DEFAULT_BYTE_RET_VALUEotherwise.
-
isEmpty
public boolean isEmpty()- Returns:
- true if this does not contain any ALetter.
-
put
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
vis present, 0xff ifvis null. - Throws:
IllegalArgumentException- if there are alreadyMAX_ALABELALPHABET_SIZEelements in the map
-
size
public int size()- Returns:
- the current size of this alphabet
-
toString
-