Package org.cesilko.rachota.gui
Class LimitedCapacityStack
java.lang.Object
org.cesilko.rachota.gui.LimitedCapacityStack
Stack with ability to keep only limited number of objects.
Object is stored only if there is another object with smaller
key or some capacity left.
-
Constructor Summary
ConstructorsConstructorDescriptionLimitedCapacityStack
(int capacity) Creates new instance of stack with given capacity. -
Method Summary
Modifier and TypeMethodDescriptiongetKeys()
Returns set of stored keys.Returns set of stored objects.void
put
(Comparable key, Object object) Tries to store given object using provided key.
-
Constructor Details
-
LimitedCapacityStack
public LimitedCapacityStack(int capacity) Creates new instance of stack with given capacity.- Parameters:
capacity
- Maximum number of objects to be stored in stack.
-
-
Method Details
-
put
Tries to store given object using provided key. If stack is not full or given key is greater than some other key, both object and key are stored in the stack. The smaller key and object are gone.- Parameters:
key
- Key to be compared with the stored keys.object
- Object that wants to be stored in the stack.
-
getKeys
Returns set of stored keys.- Returns:
- All keys stored in the stack.
-
getObjects
Returns set of stored objects.- Returns:
- All objects stored in the stack.
-