/** * Tests if the set represented by given data array contains a given object. * * @param d * the elements representing the set * @param o * the object to be tested on inclusion in the set * @return {@code true} if the object occurs in the array and {@code false} * otherwise */ static <E> boolean contains(E[] d, Object o) { int pos = getPosition(d, o); if (d[pos] == null) return false; // else return true; }
/** * Tests if the set represented by given data array contains a given object. * * @param d * the elements representing the set * @param o * the object to be tested on inclusion in the set * @return {@code true} if the object occurs in the array and {@code false} * otherwise */ static <E> boolean contains(E[] d, Object o) { int pos = getPosition(d, o); if (d[pos] == null) return false; // else return true; }
/** * Tests if the set represented by given data array contains a given object. * * @param d * the elements representing the set * @param o * the object to be tested on inclusion in the set * @return {@code true} if the object occurs in the array and {@code false} * otherwise */ static <E> boolean contains(E[] d, Object o) { int pos = getPosition(d, o); if (d[pos] == null) return false; // else return true; }
/** * Adds the element to the set represented by given data array, if it did * not contain there already. * * @param d * the elements of the set * @param e * the element to be added to the set * @return {@code true} if the set has changed (the element is added), * {@code false} otherwise */ static <E> boolean add(E[] d, E e) { int pos = getPosition(d, e); if (d[pos] == null) { d[pos] = e; return true; } // else the element is already there return false; }
/** * Adds the element to the set represented by given data array, if it did * not contain there already. * * @param d * the elements of the set * @param e * the element to be added to the set * @return {@code true} if the set has changed (the element is added), * {@code false} otherwise */ static <E> boolean add(E[] d, E e) { int pos = getPosition(d, e); if (d[pos] == null) { d[pos] = e; return true; } // else the element is already there return false; }
/** * Adds the element to the set represented by given data array, if it did * not contain there already. * * @param d * the elements of the set * @param e * the element to be added to the set * @return {@code true} if the set has changed (the element is added), * {@code false} otherwise */ static <E> boolean add(E[] d, E e) { int pos = getPosition(d, e); if (d[pos] == null) { d[pos] = e; return true; } // else the element is already there return false; }
@Override public V get(Object key) { if (key == null) throw new NullPointerException(); // to avoid problems in the middle of resizing, we copy keys and values // when they have the same size K[] k; V[] v; for (;;) { k = this.keys; v = this.values; if (k.length == v.length) break; } int pos = LinearProbing.getPosition(k, key); if (k[pos] == null) return null; // else return v[pos]; }
@Override public V get(Object key) { if (key == null) throw new NullPointerException(); // to avoid problems in the middle of resizing, we copy keys and values // when they have the same size K[] k; V[] v; for (;;) { k = this.keys; v = this.values; if (k.length == v.length) break; } int pos = LinearProbing.getPosition(k, key); if (k[pos] == null) return null; // else return v[pos]; }
@Override public V get(Object key) { if (key == null) throw new NullPointerException(); // to avoid problems in the middle of resizing, we copy keys and values // when they have the same size K[] k; V[] v; for (;;) { k = this.keys; v = this.values; if (k.length == v.length) break; } int pos = LinearProbing.getPosition(k, key); if (k[pos] == null) return null; // else return v[pos]; }
/** * Removes the element from the set represented by given data array, if it * occurs there. * * @param d * the elements of the set * @param e * the element to be removed from the array * @return {@code true} if the set has changed (the element is added), * {@code false} otherwise */ static <E> boolean remove(E[] d, Object o) { int pos = getPosition(d, o); if (d[pos] == null) return false; // else remove(d, pos); return true; } }
/** * Removes the element from the set represented by given data array, if it * occurs there. * * @param d * the elements of the set * @param e * the element to be removed from the array * @return {@code true} if the set has changed (the element is added), * {@code false} otherwise */ static <E> boolean remove(E[] d, Object o) { int pos = getPosition(d, o); if (d[pos] == null) return false; // else remove(d, pos); return true; } }
/** * Remove the entry in the keys and values such that the key of the entry is * equal to the given object according to the equality function. * * @param keys * the array of keys * @param values * the arrays of values * @param key * the key for which to delete the entry * @return the value of the deleted entry, <tt>null</tt> if nothing has been * deleted */ private static <K, V> V removeEntry(K[] keys, V[] values, Object key) { int pos = LinearProbing.getPosition(keys, key); if (keys[pos] == null) return null; // else V result = values[pos]; LinearProbing.remove(keys, values, pos); return result; }
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); }
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; }
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; }