@Override public boolean addAll(Collection<? extends E> c) { boolean modified = false; for (E entry : c) { if (add(entry)) { modified = true; } } return modified; }
/** * Add or replace an entry in the TreeSet. * * @param entry Entry to add or replace/update. * * @return the previous entry, or null if this set did not already contain the * specified entry */ public E addOrReplace(E entry) { return add(entry, true); }
@Override public boolean add(E entry) { return add(entry, false) == null; }
public AddBlockResult addBlock(BlockInfo b, Block reportedBlock) { // First check whether the block belongs to a different storage // on the same DN. AddBlockResult result = AddBlockResult.ADDED; DatanodeStorageInfo otherStorage = b.findStorageInfo(getDatanodeDescriptor()); if (otherStorage != null) { if (otherStorage != this) { // The block belongs to a different storage. Remove it first. otherStorage.removeBlock(b); result = AddBlockResult.REPLACED; } else { // The block is already associated with this storage. return AddBlockResult.ALREADY_EXIST; } } b.addStorage(this, reportedBlock); blocks.add(b); return result; }
return add(entry);