9 package javolution.util.internal.table;
57 public Object
get(
int index) {
63 public Object
set(
int index, Object element) {
66 Object previous =
data[i];
73 public void shiftLeft(Object inserted,
int last,
int length) {
75 int tail = (last +
offset) & mask;
76 int head = (last +
offset - length) & mask;
80 System.arraycopy(
data, head + 1,
data, head, mask - head);
84 System.arraycopy(
data, tail - n + 1,
data, tail - n, n);
85 data[tail] = inserted;
86 }
else if ((head <= tail) && ((head >>
shift) == (tail >>
shift))) {
89 int low = head >>
shift;
90 int high = (low !=
data.length - 1) ? low + 1 : 0;
92 while (high != (tail >>
shift)) {
94 high = (low !=
data.length - 1) ? low + 1 : 0;
96 F(low).
set(-1,
F(high).
get(0));
104 public void shiftRight(Object inserted,
int first,
int length) {
106 int head = (first +
offset) & mask;
107 int tail = (first +
offset + length) & mask;
111 System.arraycopy(
data, 0,
data, 1, tail);
115 System.arraycopy(
data, head,
data, head + 1, n);
116 data[head] = inserted;
117 }
else if ((head <= tail) && ((head >>
shift) == (tail >>
shift))) {
120 int high = tail >>
shift;
121 int low = (high != 0) ? high - 1 :
data.length - 1;
123 while (low != (head >>
shift)) {
125 low = (high != 0) ? high - 1 :
data.length - 1;
127 F(high).
set(0,
F(low).
get(-1));
151 if ((o + n) >
data.length) {
152 int w = (o + n) -
data.length;
154 System.arraycopy(
data, 0, that.
data, n, w);
156 System.arraycopy(
data, o, that.
data, 0, n);
162 new Object[1 <<
SHIFT], 0);
169 return (table !=
null) ? table :
allocate(i);