Class HistoryList<T>
java.lang.Object
top.girlkisser.lazuli.api.collections.HistoryList<T>
- Type Parameters:
T- The list's entry type.
A helper class for storing and managing a list with undo/redo capabilities.
See Minefactorial's TweakerulerHistory for a usage example.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHistoryList(int maxLength) A helper class for storing and managing a list with undo/redo capabilities. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRedo()Get whether aredo()will do anything when invoked.booleancanUndo()Get whether anundo()will do anything when invoked.voidclear()Clears all data and history from this list.intdataSize()Get the current amount of elements.intGet the current amount of elements stored in history.protected voidInvoked any timeredo()is called successfully.protected voidInvoked any timeundo()is called successfully.voidPushes an item onto the history.voidredo()Undo the lastestundo().voidundo()Undo the lastestpush(Object).
-
Field Details
-
redoHistory
-
data
The contained elements. -
maxLength
protected int maxLengthThe maximum combined length of each list.
-
-
Constructor Details
-
HistoryList
public HistoryList(int maxLength) A helper class for storing and managing a list with undo/redo capabilities.See Minefactorial's TweakerulerHistory for a usage example.
- Parameters:
maxLength- The maximum length for the list.
-
-
Method Details
-
clear
public void clear()Clears all data and history from this list. -
dataSize
public int dataSize()Get the current amount of elements.- Returns:
- The amount.
-
historySize
public int historySize()Get the current amount of elements stored in history.- Returns:
- The amount.
-
push
Pushes an item onto the history. This will remove elements after the index, if there are any.- Parameters:
it- The item to add.
-
canUndo
public boolean canUndo()Get whether anundo()will do anything when invoked.- Returns:
- `true` if there is data to undo.
-
undo
public void undo()Undo the lastestpush(Object). -
canRedo
public boolean canRedo()Get whether aredo()will do anything when invoked.- Returns:
- `true` if there is data to redo.
-
redo
public void redo()Undo the lastestundo(). -
onUndo
Invoked any timeundo()is called successfully.- Parameters:
undoneItem- The undone item.
-
onRedo
Invoked any timeredo()is called successfully.- Parameters:
redoneItem- The redone item.
-