@Override public void write(DataOutput out) throws IOException { out.writeBoolean(isSingleton); if (isSingleton) { out.writeInt(singletonIndex); out.writeFloat(singletonValue); } else { out.writeInt(entries.size()); for (int i = 0; i < entries.size(); ++i) { out.writeFloat(entries.getFloat(i)); } } }
/** * Get a particular entry of the vector. * * @param i the entry * @return the value of the entry. */ public float get(int i) { // The default value is 0.0 if (i >= entries.size()) { return 0.0f; } return entries.getFloat(i); }
/** * Resize the array to be at least the size specified. * * @param size the size of the array */ private void ensureCapacity(int size) { if (entries.size() < size) { entries.size(size); } }