/** {@inheritDoc} */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // VERSION int version = in.readByte(); // SUPER super.readExternal(in); // NUMBER OF ENTRIES int size = in.readInt(); if (version >= 1) { // LOAD FACTOR _loadFactor = in.readFloat(); // NO ENTRY VALUE no_entry_value = in.readShort(); //noinspection RedundantCast if (no_entry_value != (short) 0) { Arrays.fill(_set, no_entry_value); } } // ENTRIES setUp(size); while (size-- > 0) { short val = in.readShort(); add(val); } }
/** {@inheritDoc} */ public void clear() { super.clear(); short[] set = _set; byte[] states = _states; for (int i = set.length; i-- > 0; ) { set[i] = no_entry_value; states[i] = FREE; } }
/** {@inheritDoc} */ public void writeExternal(ObjectOutput out) throws IOException { // VERSION out.writeByte(1); // SUPER super.writeExternal(out); // NUMBER OF ENTRIES out.writeInt(_size); // LOAD FACTOR -- Added version 1 out.writeFloat(_loadFactor); // NO ENTRY VALUE -- Added version 1 out.writeShort(no_entry_value); // ENTRIES for (int i = _states.length; i-- > 0; ) { if (_states[i] == FULL) { out.writeShort(_set[i]); } } }