private static <E> void remove(byte sl, E[] data, int[] masks, int pos) { int oldFragment = getFragment(sl, masks, pos); for (;;) { int next = LinearProbing.getMovedPosition(data, pos); E moved = data[pos] = data[next]; int newFragment = getFragment(sl, masks, next); changeFragment(sl, masks, pos, oldFragment ^ newFragment); if (moved == null) return; // else pos = next; oldFragment = newFragment; } }
private static <E> void remove(byte sl, E[] data, int[] masks, int pos) { int oldFragment = getFragment(sl, masks, pos); for (;;) { int next = LinearProbing.getMovedPosition(data, pos); E moved = data[pos] = data[next]; int newFragment = getFragment(sl, masks, next); changeFragment(sl, masks, pos, oldFragment ^ newFragment); if (moved == null) return; // else pos = next; oldFragment = newFragment; } }
private static <E> void remove(byte sl, E[] data, int[] masks, int pos) { int oldFragment = getFragment(sl, masks, pos); for (;;) { int next = LinearProbing.getMovedPosition(data, pos); E moved = data[pos] = data[next]; int newFragment = getFragment(sl, masks, next); changeFragment(sl, masks, pos, oldFragment ^ newFragment); if (moved == null) return; // else pos = next; oldFragment = newFragment; } }
public boolean contains(int s, Object o) { if (o == null) throw new NullPointerException(); // to avoid problems in the middle of resizing, we copy data and masks // when they have the same size E[] d; int[] m; for (;;) { d = this.data; m = this.masks; if (m.length == getMaskCapacity(logs, d.length)) break; } int pos = LinearProbing.getPosition(d, o); if (d[pos] == null) return false; // else int mask = 1 << s; return ((getFragment(logs, m, pos) & mask) == mask); }
public boolean contains(int s, Object o) { if (o == null) throw new NullPointerException(); // to avoid problems in the middle of resizing, we copy data and masks // when they have the same size E[] d; int[] m; for (;;) { d = this.data; m = this.masks; if (m.length == getMaskCapacity(logs, d.length)) break; } int pos = LinearProbing.getPosition(d, o); if (d[pos] == null) return false; // else int mask = 1 << s; return ((getFragment(logs, m, pos) & mask) == mask); }
public boolean contains(int s, Object o) { if (o == null) throw new NullPointerException(); // to avoid problems in the middle of resizing, we copy data and masks // when they have the same size E[] d; int[] m; for (;;) { d = this.data; m = this.masks; if (m.length == getMaskCapacity(logs, d.length)) break; } int pos = LinearProbing.getPosition(d, o); if (d[pos] == null) return false; // else int mask = 1 << s; return ((getFragment(logs, m, pos) & mask) == mask); }
/** * Increasing the capacity of the table */ private void enlarge() { int oldCapacity = data.length; if (oldCapacity == LinearProbing.MAXIMUM_CAPACITY) throw new IllegalArgumentException( "The set cannot grow beyond the capacity: " + LinearProbing.MAXIMUM_CAPACITY); E[] oldData = data; int[] oldMasks = masks; int newCapacity = oldCapacity << 1; @SuppressWarnings("unchecked") E[] newData = (E[]) new Object[newCapacity]; int[] newMasks = new int[getMaskCapacity(logs, newCapacity)]; for (int i = 0; i < oldCapacity; i++) { E e = oldData[i]; if (e != null) addMask(logs, newData, newMasks, e, getFragment(logs, oldMasks, i)); } this.data = newData; this.masks = newMasks; }
/** * Increasing the capacity of the table */ private void enlarge() { int oldCapacity = data.length; if (oldCapacity == LinearProbing.MAXIMUM_CAPACITY) throw new IllegalArgumentException( "The set cannot grow beyond the capacity: " + LinearProbing.MAXIMUM_CAPACITY); E[] oldData = data; int[] oldMasks = masks; int newCapacity = oldCapacity << 1; @SuppressWarnings("unchecked") E[] newData = (E[]) new Object[newCapacity]; int[] newMasks = new int[getMaskCapacity(logs, newCapacity)]; for (int i = 0; i < oldCapacity; i++) { E e = oldData[i]; if (e != null) addMask(logs, newData, newMasks, e, getFragment(logs, oldMasks, i)); } this.data = newData; this.masks = newMasks; }
/** * Increasing the capacity of the table */ private void enlarge() { int oldCapacity = data.length; if (oldCapacity == LinearProbing.MAXIMUM_CAPACITY) throw new IllegalArgumentException( "The set cannot grow beyond the capacity: " + LinearProbing.MAXIMUM_CAPACITY); E[] oldData = data; int[] oldMasks = masks; int newCapacity = oldCapacity << 1; @SuppressWarnings("unchecked") E[] newData = (E[]) new Object[newCapacity]; int[] newMasks = new int[getMaskCapacity(logs, newCapacity)]; for (int i = 0; i < oldCapacity; i++) { E e = oldData[i]; if (e != null) addMask(logs, newData, newMasks, e, getFragment(logs, oldMasks, i)); } this.data = newData; this.masks = newMasks; }
/** * Decreasing the capacity of the table */ private void shrink() { int oldCapacity = data.length; if (oldCapacity == 1) return; E[] oldData = data; int[] oldMasks = masks; int newCapacity = oldCapacity >> 1; @SuppressWarnings("unchecked") E[] newData = (E[]) new Object[newCapacity]; int[] newMasks = new int[getMaskCapacity(logs, newCapacity)]; for (int i = 0; i < oldCapacity; i++) { E e = oldData[i]; if (e != null) addMask(logs, newData, newMasks, e, getFragment(logs, oldMasks, i)); } this.data = newData; this.masks = newMasks; }
/** * Decreasing the capacity of the table */ private void shrink() { int oldCapacity = data.length; if (oldCapacity == 1) return; E[] oldData = data; int[] oldMasks = masks; int newCapacity = oldCapacity >> 1; @SuppressWarnings("unchecked") E[] newData = (E[]) new Object[newCapacity]; int[] newMasks = new int[getMaskCapacity(logs, newCapacity)]; for (int i = 0; i < oldCapacity; i++) { E e = oldData[i]; if (e != null) addMask(logs, newData, newMasks, e, getFragment(logs, oldMasks, i)); } this.data = newData; this.masks = newMasks; }
/** * Decreasing the capacity of the table */ private void shrink() { int oldCapacity = data.length; if (oldCapacity == 1) return; E[] oldData = data; int[] oldMasks = masks; int newCapacity = oldCapacity >> 1; @SuppressWarnings("unchecked") E[] newData = (E[]) new Object[newCapacity]; int[] newMasks = new int[getMaskCapacity(logs, newCapacity)]; for (int i = 0; i < oldCapacity; i++) { E e = oldData[i]; if (e != null) addMask(logs, newData, newMasks, e, getFragment(logs, oldMasks, i)); } this.data = newData; this.masks = newMasks; }
private static <E> int removeMask(byte sl, E[] data, int[] masks, Object o, int mask) { int pos = LinearProbing.getPosition(data, o); if (data[pos] == null) return 0; // else int oldFragment = getFragment(sl, masks, pos); int newFragment = oldFragment & (~mask); if (newFragment == 0) remove(sl, data, masks, pos); else changeFragment(sl, masks, pos, oldFragment ^ newFragment); return oldFragment; }
private static <E> int removeMask(byte sl, E[] data, int[] masks, Object o, int mask) { int pos = LinearProbing.getPosition(data, o); if (data[pos] == null) return 0; // else int oldFragment = getFragment(sl, masks, pos); int newFragment = oldFragment & (~mask); if (newFragment == 0) remove(sl, data, masks, pos); else changeFragment(sl, masks, pos, oldFragment ^ newFragment); return oldFragment; }
private static <E> int addMask(byte sl, E[] data, int[] masks, E e, int mask) { int pos = LinearProbing.getPosition(data, e); int oldMask = getFragment(sl, masks, pos); if (data[pos] == null) { data[pos] = e; changeFragment(sl, masks, pos, oldMask ^ mask); return 0; } // else int newMask = (oldMask | mask); if (newMask != oldMask) changeFragment(sl, masks, pos, oldMask ^ newMask); return oldMask; }
private static <E> int addMask(byte sl, E[] data, int[] masks, E e, int mask) { int pos = LinearProbing.getPosition(data, e); int oldMask = getFragment(sl, masks, pos); if (data[pos] == null) { data[pos] = e; changeFragment(sl, masks, pos, oldMask ^ mask); return 0; } // else int newMask = (oldMask | mask); if (newMask != oldMask) changeFragment(sl, masks, pos, oldMask ^ newMask); return oldMask; }
private static <E> int addMask(byte sl, E[] data, int[] masks, E e, int mask) { int pos = LinearProbing.getPosition(data, e); int oldMask = getFragment(sl, masks, pos); if (data[pos] == null) { data[pos] = e; changeFragment(sl, masks, pos, oldMask ^ mask); return 0; } // else int newMask = (oldMask | mask); if (newMask != oldMask) changeFragment(sl, masks, pos, oldMask ^ newMask); return oldMask; }
private static <E> int removeMask(byte sl, E[] data, int[] masks, Object o, int mask) { int pos = LinearProbing.getPosition(data, o); if (data[pos] == null) return 0; // else int oldFragment = getFragment(sl, masks, pos); int newFragment = oldFragment & (~mask); if (newFragment == 0) remove(sl, data, masks, pos); else changeFragment(sl, masks, pos, oldFragment ^ newFragment); return oldFragment; }