/** * Copy given set. * * @param <E> * @param set * @return */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static <E> Set<E> copy(Set<E> set) { if (set instanceof ONDEXSet) { ONDEXSet sat = (ONDEXSet) set; return sat.clone(); } else { return new HashSet<E>(set); } }
/** * returns false if the element is not contained in the view or if the * user has no permission to view the element. * * @throws net.sourceforge.ondex.exception.type.AccessDeniedException * if the object parameter does not provide read permission. */ @Override public boolean contains(Object o) { if (o != null && getDataType().isAssignableFrom(o.getClass())) { if (o instanceof ONDEXEntity) { ONDEXEntity e = (ONDEXEntity) o; return set.get(e.getId()); } } return false; }
@Override public AnyType next() { currentIndex = nextIndex; nextIndex = set.nextSetBit(currentIndex + 1); return reallyGetEntity(currentIndex); }
/** * Checks for all objects of a given Collection to be contained in this * iterator. * * @param c * Collection<?> * @return boolean * @throws net.sourceforge.ondex.exception.type.AccessDeniedException */ @Override public boolean containsAll(Collection<?> c) { if (size() == 0) return false; for (Object aC : c) { if (!contains(aC)) { return false; } } return true; }
/** * Returns true if this collection contains no elements. * * @return true if this collection contains no elements */ @Override public boolean isEmpty() { return (size() == 0); }