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
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: 886 $
- Author:
- posenato
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
ALetter makes simpler to check if a node name is appropriate. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
A-Letter.static final String
A-Letter range.static final ALabelAlphabet.ALetter
Default value for not found index.static final byte
Default value for not found name.static final byte
Maximum size for the alphabet.(package private) static final long
Serial number -
Constructor Summary
ConstructorDescriptionDefault constructor.ALabelAlphabet
(int size1) ALabelAlphabet
(ALabelAlphabet alpha) Constructor by copy. -
Method Summary
-
Field Details
-
ALETTER
-
ALETTER_RANGE
-
DEFAULT_ALETTER_RET_VALUE
Default value for not found index. -
DEFAULT_BYTE_RET_VALUE
public static final byte DEFAULT_BYTE_RET_VALUEDefault value for not found name.- See Also:
-
MAX_ALABELALPHABET_SIZE
public static final byte MAX_ALABELALPHABET_SIZEMaximum size for the alphabet. Such limitation is dictated by the ALabel class implementation.- 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
-
index
- Parameters:
name
- the input a-letter- Returns:
- the index associated to name if it exists,
DEFAULT_BYTE_RET_VALUE
otherwise
-
get
- 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
-
isEmpty
public boolean isEmpty()- Returns:
- true is this does not contain a-letter
-
put
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 ifv
is null - Throws:
IllegalArgumentException
- if there are alreadyMAX_ALABELALPHABET_SIZE
elements in the map
-
size
public int size()- Returns:
- the current size of this alphabet
-
toString
-