java.lang.Object
javafx.beans.binding.ListExpression<E>
javafx.beans.property.ReadOnlyListProperty<E>
javafx.beans.property.ListProperty<E>
javafx.beans.property.ListPropertyBase<E>
javafx.beans.property.SimpleListProperty<E>
io.github.palexdev.materialfx.collections.ObservableStack<E>
- Type Parameters:
E- Any type
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>,Observable,Property<ObservableList<E>>,ReadOnlyProperty<ObservableList<E>>,ObservableListValue<E>,ObservableObjectValue<ObservableList<E>>,ObservableValue<ObservableList<E>>,WritableListValue<E>,WritableObjectValue<ObservableList<E>>,WritableValue<ObservableList<E>>,ObservableList<E>
A crude implementation of an observable stack It includes the main features of a stack namely:
push and pop.
-
Property Summary
Properties inherited from class javafx.beans.property.ListPropertyBase
empty, size -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an element to the given indexbooleanPushes the element to the top of the stackbooleanaddAll(int i, Collection<? extends E> elements) booleanAdds the contents of the array into the stackbooleanaddAll(Collection<? extends E> elements) Adds the elements from the collection into the stack in the order they are specifiedpop()Places the item at the top of the stackremove(int i) Removes an element at the given indexvoidremove(int from, int to) Attempt to remove a range of objects from the stack, this is also not permittedbooleanAttempt to remove an arbitrary object from the stack is not permittedbooleanEffectively empties the stack given that the stack is not already emptybooleanbooleanremoveAll(Collection<?> objects) Methods inherited from class javafx.beans.property.SimpleListProperty
getBean, getNameMethods inherited from class javafx.beans.property.ListPropertyBase
addListener, addListener, addListener, bind, emptyProperty, fireValueChangedEvent, fireValueChangedEvent, get, invalidated, isBound, removeListener, removeListener, removeListener, set, sizeProperty, toString, unbindMethods inherited from class javafx.beans.property.ListProperty
bindBidirectional, setValue, unbindBidirectionalMethods inherited from class javafx.beans.property.ReadOnlyListProperty
bindContent, bindContentBidirectional, equals, hashCode, unbindContent, unbindContentBidirectionalMethods inherited from class javafx.beans.binding.ListExpression
asString, clear, contains, containsAll, get, getSize, getValue, indexOf, isEmpty, isEqualTo, isNotEqualTo, isNotNull, isNull, iterator, lastIndexOf, listExpression, listIterator, listIterator, retainAll, retainAll, set, setAll, setAll, size, subList, toArray, toArray, valueAt, valueAtMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArrayMethods inherited from interface javafx.collections.ObservableList
filtered, retainAll, setAll, setAll, sorted, sortedMethods inherited from interface javafx.beans.value.ObservableValue
getValueMethods inherited from interface javafx.beans.value.WritableValue
getValue
-
Constructor Details
-
ObservableStack
public ObservableStack()
-
-
Method Details
-
push
Places the item at the top of the stack- Parameters:
item- the item- Returns:
- the item that was just pushed
-
pop
- Returns:
- the item at the top of the stack granted that the stack is not empty
- Throws:
NoSuchElementException- if the stack is empty
-
add
Pushes the element to the top of the stack- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceList<E>- Overrides:
addin classListExpression<E>- Parameters:
element- the element to add- Returns:
- Always returns true
- See Also:
-
remove
Removes an element at the given index- Specified by:
removein interfaceList<E>- Overrides:
removein classListExpression<E>- Parameters:
i- the index to remove from- Returns:
- The element that was removed
- Throws:
IllegalArgumentException- if i is not 0. The stack can only access the top element- See Also:
-
removeAll
Effectively empties the stack given that the stack is not already empty- Returns:
- true if the stack was emptied
- Throws:
NoSuchElementException- if the stack is already empty
-
add
Adds an element to the given index- Specified by:
addin interfaceList<E>- Overrides:
addin classListExpression<E>- Parameters:
i- the index to add the element atelement- the element to add to the stack- Throws:
IllegalArgumentException- if the index specified is not 0. Only the top of the stack is accessible- See Also:
-
addAll
Adds the elements from the collection into the stack in the order they are specified- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceList<E>- Overrides:
addAllin classListExpression<E>- Parameters:
elements- the collection to be added to this stack- Returns:
- true
- Throws:
NullPointerException- if the collection is null
-
addAll
Adds the contents of the array into the stack- Specified by:
addAllin interfaceObservableList<E>- Overrides:
addAllin classListExpression<E>- Parameters:
elements- the array of elements to add- Returns:
- true
- See Also:
-
addAll
-
remove
Attempt to remove an arbitrary object from the stack is not permitted- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceList<E>- Overrides:
removein classListExpression<E>- Parameters:
obj- The object to remove- Returns:
- Nothing
- Throws:
UnsupportedOperationException- Removing an arbitrary object is not permitted Usepop()
-
remove
Attempt to remove a range of objects from the stack, this is also not permitted- Specified by:
removein interfaceObservableList<E>- Overrides:
removein classListExpression<E>- Parameters:
from- Start removing from hereto- To here- Throws:
UnsupportedOperationException-remove(Object)
-
removeAll
- Specified by:
removeAllin interfaceObservableList<E>- Overrides:
removeAllin classListExpression<E>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceList<E>- Overrides:
removeAllin classListExpression<E>
-