Package jsonvalues
Interface MutableSeq
-
public interface MutableSeqRepresents a mutable data structure where elements of a JsArray are stored. Each mutable Json factoryMutableJsonshas an implementation of this interface, that can be defined using the methodMutableJsons.withSeq(Class). The default mutable implementation thatJsons.mutableuses is the JavaArrayList
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidadd(int index, JsElem ele)adds an element at the index, shifting elements at greater or equal indexes one position to the right.voidappendBack(JsElem elem)appends the element to the back of the seqvoidappendFront(JsElem elem)appends the element to the front of the seqbooleancontains(JsElem e)returns true if the seq contains the elementMutableSeqcopy()creates and returns a copy of this sequenceJsElemget(int index)returns the element located at the index.JsElemhead()returns the first element of the seq.Vinit()booleanisEmpty()returns true if this seq is emptyJsElemlast()returns the last element of the seq.voidremove(int index)removes the element located at the index.intsize()returns the size of the seqVtail()voidupdate(int index, JsElem ele)updates the element located at the index with a new element.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
copy
MutableSeq copy()
creates and returns a copy of this sequence- Returns:
- a new instance
-
appendFront
void appendFront(JsElem elem)
appends the element to the front of the seq- Parameters:
elem- the given element
-
appendBack
void appendBack(JsElem elem)
appends the element to the back of the seq- Parameters:
elem- the given element
-
update
void update(int index, JsElem ele)updates the element located at the index with a new element. It will be called by the library only if the index exists- Parameters:
index- the given indexele- the given element
-
add
void add(int index, JsElem ele)adds an element at the index, shifting elements at greater or equal indexes one position to the right. It's called by the library only if the index exists- Parameters:
index- the given indexele- the given element
-
remove
void remove(int index)
removes the element located at the index. It will be called by the library only if the index exists- Parameters:
index- the given index
-
head
JsElem head()
returns the first element of the seq. It's called by the library only if the seq is not empty- Returns:
- the first element of the seq
-
tail
V tail()
-
init
V init()
-
last
JsElem last()
returns the last element of the seq. It's called by the library only if the seq is not empty- Returns:
- the last element of the seq
-
get
JsElem get(int index)
returns the element located at the index. It's called by the library only if the index exists- Parameters:
index- the given index- Returns:
- the element located at the index
-
size
int size()
returns the size of the seq- Returns:
- the size of the seq
-
isEmpty
boolean isEmpty()
returns true if this seq is empty- Returns:
- true if empty, false otherwise
-
contains
boolean contains(JsElem e)
returns true if the seq contains the element- Parameters:
e- the given element- Returns:
- true if the seq contains the element, false otherwise
-
-