Force a garbage collection event. This removes all items which are unreachable from the root, and compacts those remaining down. @return
()
| 192 | * @return |
| 193 | */ |
| 194 | @Override |
| 195 | public boolean gc() { |
| 196 | // Mark all reachable items |
| 197 | BitSet reachable = findReachable(getRootItem(), new BitSet()); |
| 198 | // Sweep all unreachable items away |
| 199 | int count = 0; |
| 200 | for(int i=0;i!=syntacticItems.size();++i) { |
| 201 | if(reachable.get(i)) { |
| 202 | Item item = syntacticItems.get(i); |
| 203 | // Reset the index of this item |
| 204 | item.allocate(this, count); |
| 205 | // Move the item down |
| 206 | syntacticItems.set(count++, item); |
| 207 | } |
| 208 | } |
| 209 | // Remove all unreachable items. |
| 210 | for (int i = syntacticItems.size(); i > count; i = i - 1) { |
| 211 | syntacticItems.remove(i - 1); |
| 212 | } |
| 213 | // Indicate whether anything changed |
| 214 | return count < syntacticItems.size(); |
| 215 | } |
| 216 | |
| 217 | public void print(PrintWriter out) { |
| 218 | String lenStr = Integer.toString(syntacticItems.size()); |
nothing calls this directly
no test coverage detected