cz.cuni.astar
Class AStarHeap
java.lang.Object
cz.cuni.astar.AStarHeap
- All Implemented Interfaces:
- java.lang.Iterable, java.util.Collection
public class AStarHeap
- extends java.lang.Object
- implements java.util.Collection
This is Heap used by AStar algorithm.
Note that we assume that inserted Object has correctly implemented hashCode()
and equals() function!
Field Summary |
private java.util.Comparator |
cmp
|
private int |
count
|
private int |
items
|
private java.lang.Object[] |
nodes
|
private java.util.HashMap |
references
|
Constructor Summary |
AStarHeap(java.util.Comparator comp)
|
AStarHeap(java.util.Comparator comp,
int capacity)
|
Method Summary |
boolean |
add(java.lang.Object arg0)
|
boolean |
addAll(java.util.Collection arg0)
|
boolean |
addAll(java.lang.Object[] arg0)
|
void |
clear()
|
boolean |
contains(java.lang.Object arg0)
|
boolean |
containsAll(java.util.Collection arg0)
|
boolean |
containsAll(java.lang.Object[] arg0)
|
boolean |
decreaseKey(java.lang.Object arg0)
|
boolean |
deleteMin()
|
private int |
downNode(int reference)
|
boolean |
empty()
|
java.lang.Object |
getMin()
|
private java.lang.Object |
getNode(int reference)
|
private void |
grow()
|
private void |
initHeap(int capacity)
|
boolean |
isEmpty()
|
java.util.Iterator |
iterator()
|
private int |
left(int reference)
|
static void |
main(java.lang.String[] args)
|
static void |
mainAdd(AStarHeap heap,
java.lang.Integer[] nums)
|
static boolean |
mainCheck(AStarHeap heap,
java.lang.Integer[] nums)
|
static java.lang.String |
mainToStr(java.lang.Integer[] nums)
|
boolean |
remove(java.lang.Object arg0)
|
private boolean |
remove(java.lang.Object arg0,
int reference)
|
boolean |
removeAll(java.util.Collection arg0)
|
boolean |
retainAll(java.util.Collection arg0)
|
private int |
right(int reference)
|
int |
size()
|
java.lang.Object[] |
toArray()
|
java.lang.Object[] |
toArray(java.lang.Object[] arg0)
|
java.util.Set |
toSet()
|
private int |
upNode(int reference)
|
private int |
upRef(int reference)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Collection |
equals, hashCode |
nodes
private java.lang.Object[] nodes
count
private int count
items
private int items
references
private java.util.HashMap references
cmp
private java.util.Comparator cmp
AStarHeap
public AStarHeap(java.util.Comparator comp,
int capacity)
AStarHeap
public AStarHeap(java.util.Comparator comp)
grow
private void grow()
left
private int left(int reference)
right
private int right(int reference)
upRef
private int upRef(int reference)
getNode
private java.lang.Object getNode(int reference)
downNode
private int downNode(int reference)
upNode
private int upNode(int reference)
initHeap
private void initHeap(int capacity)
getMin
public java.lang.Object getMin()
deleteMin
public boolean deleteMin()
decreaseKey
public boolean decreaseKey(java.lang.Object arg0)
add
public boolean add(java.lang.Object arg0)
- Specified by:
add
in interface java.util.Collection
addAll
public boolean addAll(java.util.Collection arg0)
- Specified by:
addAll
in interface java.util.Collection
addAll
public boolean addAll(java.lang.Object[] arg0)
clear
public void clear()
- Specified by:
clear
in interface java.util.Collection
contains
public boolean contains(java.lang.Object arg0)
- Specified by:
contains
in interface java.util.Collection
containsAll
public boolean containsAll(java.util.Collection arg0)
- Specified by:
containsAll
in interface java.util.Collection
containsAll
public boolean containsAll(java.lang.Object[] arg0)
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interface java.util.Collection
iterator
public java.util.Iterator iterator()
- Specified by:
iterator
in interface java.lang.Iterable
- Specified by:
iterator
in interface java.util.Collection
remove
private boolean remove(java.lang.Object arg0,
int reference)
remove
public boolean remove(java.lang.Object arg0)
- Specified by:
remove
in interface java.util.Collection
removeAll
public boolean removeAll(java.util.Collection arg0)
- Specified by:
removeAll
in interface java.util.Collection
retainAll
public boolean retainAll(java.util.Collection arg0)
- Specified by:
retainAll
in interface java.util.Collection
size
public int size()
- Specified by:
size
in interface java.util.Collection
empty
public boolean empty()
toArray
public java.lang.Object[] toArray()
- Specified by:
toArray
in interface java.util.Collection
toArray
public java.lang.Object[] toArray(java.lang.Object[] arg0)
- Specified by:
toArray
in interface java.util.Collection
toSet
public java.util.Set toSet()
mainToStr
public static java.lang.String mainToStr(java.lang.Integer[] nums)
mainCheck
public static boolean mainCheck(AStarHeap heap,
java.lang.Integer[] nums)
mainAdd
public static void mainAdd(AStarHeap heap,
java.lang.Integer[] nums)
main
public static void main(java.lang.String[] args)