|
| 1 | +# Class BinaryHeap |
| 2 | + |
| 3 | +* Version: package.version |
| 4 | +* Author: xdf |
| 5 | + |
| 6 | +[doc2](https://commons.apache.org/proper/commons-collections/javadocs/api-2.1.1/org/apache/commons/collections/BinaryHeap.html) |
| 7 | + |
| 8 | +## Constructor Detail |
| 9 | + |
| 10 | +### BinaryHeap() |
| 11 | + |
| 12 | +Constructs a new minimum binary heap. |
| 13 | + |
| 14 | + |
| 15 | +### BinaryHeap(Array comparator) |
| 16 | + |
| 17 | +Constructs a new BinaryHeap that will use the given comparator to order its elements. |
| 18 | + |
| 19 | +### BinaryHeap(Number capacity) |
| 20 | + |
| 21 | +Constructs a new minimum binary heap with the specified initial capacity. |
| 22 | + |
| 23 | +` Parameters: ` |
| 24 | + |
| 25 | +* capacity - The initial capacity for the heap. This value must be greater than zero. |
| 26 | + |
| 27 | +` Throws: ` |
| 28 | + |
| 29 | +* IllegalArgumentException - if capacity is <= 0 |
| 30 | + |
| 31 | +### BinaryHeap(Number capacity, Array comparator) |
| 32 | + |
| 33 | +Constructs a new BinaryHeap. |
| 34 | + |
| 35 | +` Parameters: ` |
| 36 | + |
| 37 | +* capacity - the initial capacity for the heap |
| 38 | +* comparator - the comparator used to order the elements, null means use natural order |
| 39 | + |
| 40 | +` Throws: ` |
| 41 | + |
| 42 | +* IllegalArgumentException - if capacity is <= 0 |
| 43 | + |
| 44 | + |
| 45 | +## Method Detail |
| 46 | + |
| 47 | +### void clear() |
| 48 | + |
| 49 | +Clears all elements from queue. |
| 50 | + |
| 51 | +### boolean isEmpty() |
| 52 | + |
| 53 | +Tests if queue is empty. |
| 54 | + |
| 55 | +` Returns: ` |
| 56 | + |
| 57 | +* true if queue is empty; false otherwise. |
| 58 | + |
| 59 | +### boolean isFull() |
| 60 | + |
| 61 | +Tests if queue is full. |
| 62 | + |
| 63 | +` Returns: ` |
| 64 | + |
| 65 | +* true if queue is full; false otherwise. |
| 66 | + |
| 67 | +### void insert(Object element) |
| 68 | + |
| 69 | +Inserts an element into queue. |
| 70 | + |
| 71 | +` Parameters: ` |
| 72 | + |
| 73 | +* element - the element to be inserted |
| 74 | + |
| 75 | +### object peek() |
| 76 | + |
| 77 | +Returns the element on top of heap but don't remove it. |
| 78 | + |
| 79 | +` Returns: ` |
| 80 | + |
| 81 | +* the element at top of heap |
| 82 | + |
| 83 | +` Throws: ` |
| 84 | + |
| 85 | +* NoSuchElementException - if isEmpty() == true |
| 86 | + |
| 87 | +### object pop() |
| 88 | + |
| 89 | +Returns the element on top of heap and remove it. |
| 90 | + |
| 91 | +` Returns: ` |
| 92 | + |
| 93 | +* the element at top of heap |
| 94 | + |
| 95 | +` Throws: ` |
| 96 | + |
| 97 | +* NoSuchElementException - if isEmpty() == true |
| 98 | + |
| 99 | + |
| 100 | +### string toString() |
| 101 | + |
| 102 | +Returns a string representation of this heap. |
| 103 | + |
| 104 | +` Returns: ` |
| 105 | + |
| 106 | +* a string representation of this heap |
| 107 | + |
| 108 | +### object iterator() |
| 109 | + |
| 110 | +Returns an iterator over this heap's elements. |
| 111 | + |
| 112 | +` Returns: ` |
| 113 | + |
| 114 | +* an iterator over this heap's elements |
| 115 | + |
| 116 | +### boolean add(Object object) |
| 117 | + |
| 118 | +Adds an object to this heap. Same as insert(Object). |
| 119 | + |
| 120 | +` Parameters: ` |
| 121 | + |
| 122 | +* object - the object to add |
| 123 | + |
| 124 | +` Returns: ` |
| 125 | + |
| 126 | +* true, always |
| 127 | + |
| 128 | +### object get() |
| 129 | + |
| 130 | +Returns the priority element. Same as peek(). |
| 131 | + |
| 132 | +` Returns: ` |
| 133 | + |
| 134 | +* the priority element |
| 135 | + |
| 136 | +` Throws: ` |
| 137 | + |
| 138 | +* BufferUnderflowException - if this heap is empty |
| 139 | + |
| 140 | +### object remove |
| 141 | + |
| 142 | +Removes the priority element. Same as pop(). |
| 143 | + |
| 144 | +` Returns: ` |
| 145 | + |
| 146 | +* the removed priority element |
| 147 | + |
| 148 | +` Throws: ` |
| 149 | + |
| 150 | +* BufferUnderflowException - if this heap is empty |
| 151 | + |
| 152 | +### number size |
| 153 | + |
| 154 | +Returns the number of elements in this heap. |
| 155 | + |
| 156 | +` Returns: ` |
| 157 | + |
| 158 | +* the number of elements in this heap |
| 159 | + |
| 160 | +## License |
| 161 | + |
| 162 | +The MIT License (MIT) |
| 163 | + |
| 164 | +Copyright (c) 2013 xdf |
| 165 | + |
| 166 | +Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 167 | +this software and associated documentation files (the "Software"), to deal in |
| 168 | +the Software without restriction, including without limitation the rights to |
| 169 | +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
| 170 | +the Software, and to permit persons to whom the Software is furnished to do so, |
| 171 | +subject to the following conditions: |
| 172 | + |
| 173 | +The above copyright notice and this permission notice shall be included in all |
| 174 | +copies or substantial portions of the Software. |
| 175 | + |
| 176 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 177 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 178 | +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 179 | +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 180 | +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 181 | +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
0 commit comments