/** * Clears all slices of this {@link ArraySlicedSet}. After calling this * methods, all slices are empty. */ @SuppressWarnings("unchecked") public void clear() { int capacity = data.length >> 2; if (capacity == 0) capacity = 1; initSizes(); this.data = (E[]) new Object[capacity]; this.masks = new int[getMaskCapacity(logs, capacity)]; }
/** * Clears all slices of this {@link ArraySlicedSet}. After calling this * methods, all slices are empty. */ @SuppressWarnings("unchecked") public void clear() { int capacity = data.length >> 2; if (capacity == 0) capacity = 1; initSizes(); this.data = (E[]) new Object[capacity]; this.masks = new int[getMaskCapacity(logs, capacity)]; }
/** * Clears all slices of this {@link ArraySlicedSet}. After calling this * methods, all slices are empty. */ @SuppressWarnings("unchecked") public void clear() { int capacity = data.length >> 2; if (capacity == 0) capacity = 1; initSizes(); this.data = (E[]) new Object[capacity]; this.masks = new int[getMaskCapacity(logs, capacity)]; }
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); }
@SuppressWarnings("unchecked") public ArraySlicedSet(int slices, int initialCapacity) { if (slices <= 0 || slices > MAX_SLICES) throw new IllegalArgumentException( "The nuber of slices should be between 1 and " + MAX_SLICES + ": " + slices); int capacity = LinearProbing.getInitialCapacity(initialCapacity); this.data = (E[]) new Object[capacity]; this.logs = (byte) upperLog(slices); this.masks = new int[getMaskCapacity(logs, capacity)]; this.sizes = new int[slices]; initSizes(); }
@SuppressWarnings("unchecked") public ArraySlicedSet(int slices, int initialCapacity) { if (slices <= 0 || slices > MAX_SLICES) throw new IllegalArgumentException( "The nuber of slices should be between 1 and " + MAX_SLICES + ": " + slices); int capacity = LinearProbing.getInitialCapacity(initialCapacity); this.data = (E[]) new Object[capacity]; this.logs = (byte) upperLog(slices); this.masks = new int[getMaskCapacity(logs, capacity)]; this.sizes = new int[slices]; initSizes(); }
@SuppressWarnings("unchecked") public ArraySlicedSet(int slices, int initialCapacity) { if (slices <= 0 || slices > MAX_SLICES) throw new IllegalArgumentException( "The nuber of slices should be between 1 and " + MAX_SLICES + ": " + slices); int capacity = LinearProbing.getInitialCapacity(initialCapacity); this.data = (E[]) new Object[capacity]; this.logs = (byte) upperLog(slices); this.masks = new int[getMaskCapacity(logs, capacity)]; this.sizes = new int[slices]; initSizes(); }
/** * 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; }