Skip to content
Snippets Groups Projects
Commit 36b0dcf6 authored by Jonas Fonseca's avatar Jonas Fonseca Committed by Shawn O. Pearce
Browse files

Make it possible to clear a PlotCommitList


This allows SwingGraphPanes to be reused by simply clearing and
re-filling. Requires RevObjectList initialization to not call clear()
from its constructor, because this will lead PlotCommitList.clear()
to be called before all variables have been initialized.

Change-Id: I14a07124441b58cd88c67da088ba52ef9c30b043
Signed-off-by: default avatarJonas Fonseca <fonseca@diku.dk>
Signed-off-by: default avatarShawn O. Pearce <spearce@spearce.org>
parent 96690904
No related branches found
No related tags found
No related merge requests found
......@@ -70,7 +70,15 @@ public class PlotCommitList<L extends PlotLane> extends
private final TreeSet<Integer> freeLanes = new TreeSet<Integer>();
private HashSet<PlotLane> activeLanes = new HashSet<PlotLane>(32);
private final HashSet<PlotLane> activeLanes = new HashSet<PlotLane>(32);
@Override
public void clear() {
super.clear();
lanesAllocated = 0;
freeLanes.clear();
activeLanes.clear();
}
@Override
public void source(final RevWalk w) {
......@@ -139,7 +147,7 @@ protected void enter(final int index, final PlotCommit<L> currCommit) {
final PlotCommit c = currCommit.children[i];
if (activeLanes.remove(c.lane)) {
recycleLane((L) c.lane);
freeLanes.add(Integer.valueOf(c.lane.position));
freeLanes.add(Integer.valueOf(c.lane.getPosition()));
}
}
......
/*
* Copyright (C) 2009, Jonas Fonseca <fonseca@diku.dk>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
* and other copyright owners as documented in the project's IP log.
*
......@@ -56,13 +57,12 @@ public class RevObjectList<E extends RevObject> extends AbstractList<E> {
static final int BLOCK_SIZE = 1 << BLOCK_SHIFT;
Block contents;
protected Block contents = new Block(0);
int size;
protected int size = 0;
/** Create an empty object list. */
public RevObjectList() {
clear();
}
public void add(final int index, final E element) {
......@@ -113,7 +113,7 @@ public void clear() {
size = 0;
}
static class Block {
protected static class Block {
final Object[] contents = new Object[BLOCK_SIZE];
final int shift;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment