*/
public void addShift(int pos, int shift)
{
- int sidx = 0;
- int[] rshift = null;
- while (sidx < shifts.size() && (rshift = shifts.get(sidx))[0] < pos)
- {
- sidx++;
- }
- if (sidx == shifts.size())
+ synchronized (shifts)
{
- shifts.add(sidx, new int[]
- { pos, shift });
- }
- else
- {
- rshift[1] += shift;
+ int sidx = 0;
+ int[] rshift = null;
+ while (sidx < shifts.size() && (rshift = shifts.get(sidx))[0] < pos)
+ {
+ sidx++;
+ }
+ if (sidx == shifts.size())
+ {
+ shifts.add(sidx, new int[]
+ { pos, shift });
+ }
+ else
+ {
+ rshift[1] += shift;
+ }
}
}
/**
* clear all shifts
*/
- public void clear()
+ public synchronized void clear()
{
shifts.clear();
}
public ShiftList getInverse()
{
ShiftList inverse = new ShiftList();
- if (shifts != null)
+ synchronized (shifts)
{
- for (int i = 0, j = shifts.size(); i < j; i++)
+ if (shifts != null)
{
- int[] sh = shifts.get(i);
- if (sh != null)
+ for (int[] sh : shifts)
{
- inverse.shifts.add(new int[]
- { sh[0], -sh[1] });
+ if (sh != null)
+ {
+ inverse.shifts.add(new int[]
+ { sh[0], -sh[1] });
+ }
}
}
}