|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjbil.sequence.Sequence
jbil.sequence.ByteArraySequence
public class ByteArraySequence
Implementation of Sequence in which the sequence of symbols is translated into an array of bytes s.t. each position represents the position of the corresponding symbol in the underlying alphabet. It assumes therefore that the alphabet is constant and that it contains no more than 127 symbols. This implementation offers a reasonable compromise between time and space efficiency for most real-world alphabets.
Constructor Summary | |
---|---|
ByteArraySequence(Alphabet alphabet)
Creates an empty sequence over a given alphabet. |
|
ByteArraySequence(Alphabet alphabet,
int initialCapacity)
Creates an empty sequence with a given initial capacity over a given alphabet. |
Method Summary | |
---|---|
void |
append(ByteArraySequence sequence)
Optmised append operation for the case in which the operand is known to be of the same type. |
void |
append(Sequence sequence)
Appends a sequence to this sequence. |
void |
append(Symbol s)
Appends a symbol to this sequence. |
Sequence |
clone()
|
void |
delete(int beginIndex,
int endIndex)
Deletes a subsequence of this sequence. |
boolean |
equals(java.lang.Object other)
|
Alphabet |
getAlphabet()
|
int |
hashCode()
|
int |
indexAt(int index)
Gets the position in the base alphabet of the symbol at a given position in the sequence. |
void |
insert(int index,
Sequence sequence)
Inserts a sequence at a given position in this sequence. |
void |
insert(int index,
Symbol s)
Inserts a new symbol at a given position in this sequence. |
int |
length()
|
void |
prepend(Sequence sequence)
Prepends a sequence to this sequence. |
void |
prepend(Symbol s)
Prepends a symbol to this sequence. |
void |
setSymbolAt(int index,
Symbol s)
Sets the symbol at a given position in this sequence. |
Sequence |
subSequence(int beginIndex)
Gets a new sequence that is a suffix of this sequence. |
Sequence |
subSequence(int beginIndex,
int endIndex)
Gets a new sequence that is a subsequence of this sequence. |
Symbol |
symbolAt(int index)
Gets the symbol at a given position in the sequence. |
java.lang.String |
toString(int beginIndex,
int endIndex)
Returns the srting representation of a subsequence of this sequence. |
Methods inherited from class jbil.sequence.Sequence |
---|
endsWith, getName, occursAt, setName, startsWith, toString |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ByteArraySequence(Alphabet alphabet)
alphabet
- The base alphabet.public ByteArraySequence(Alphabet alphabet, int initialCapacity)
alphabet
- The base alphabet.initialCapacity
- The initial capacity.Method Detail |
---|
public void append(Symbol s)
Sequence
append
in class Sequence
s
- The symbol to be appended.public void append(Sequence sequence)
Sequence
append
in class Sequence
sequence
- The sequence to be appended.public void append(ByteArraySequence sequence)
public Sequence clone()
clone
in class Sequence
public void insert(int index, Symbol s)
Sequence
insert
in class Sequence
index
- The position at which the symbol is inserted.s
- The symbol to be inserted.public void insert(int index, Sequence sequence)
Sequence
insert
in class Sequence
index
- The position at which the sequence is inserted.sequence
- The sequence to be inserted.public int length()
length
in class Sequence
public void prepend(Symbol s)
Sequence
prepend
in class Sequence
s
- The symbol to be prepended.public void prepend(Sequence sequence)
Sequence
prepend
in class Sequence
sequence
- The sequence to be prepended.public void setSymbolAt(int index, Symbol s)
Sequence
setSymbolAt
in class Sequence
index
- The position to be set.s
- The new symbol.public Sequence subSequence(int beginIndex)
Sequence
subSequence
in class Sequence
beginIndex
- The start position of the suffix.
public Sequence subSequence(int beginIndex, int endIndex)
Sequence
subSequence
in class Sequence
beginIndex
- The start position of the subsequence.endIndex
- The end position of the subsequence.
public void delete(int beginIndex, int endIndex)
Sequence
delete
in class Sequence
beginIndex
- The start position of the subsequence to be deleted.endIndex
- The end position (not inclusive) of the subsequence to be deleted.public Symbol symbolAt(int index)
Sequence
symbolAt
in class Sequence
index
- A position in the sequence.
public int indexAt(int index)
Sequence
indexAt
in class Sequence
index
- A position in the sequence.
public java.lang.String toString(int beginIndex, int endIndex)
Sequence
toString
in class Sequence
beginIndex
- The start position of the subsequence.endIndex
- The end position of the subsequence.
public Alphabet getAlphabet()
getAlphabet
in class Sequence
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |