/** * Returns an iterator over the elements in this set in frequency order. */ @Override public Iterator<E> iterator() { ensureSorted(); return new Iter(sorted, 0, sorted.length); }
/** * Returns a view of the portion of this set whose elements occur with a frequency equal or greater than * {@code fromElement} frequency. * * @param fromElement low endpoint (inclusive) of the returned set. May be {@code null}. * @return a view of the portion of this set delimited by the given endpoint. */ @Override public SortedSet<E> tailSet(final E fromElement) { return new SubSet(true, fromElement, false, null); }
/** * Returns the count of element in this set. * * @return number of elements in this set. */ @Override public synchronized int size() { assert isValid(); return count; }
/** * Replaces the given transform by a unique instance, if one already exists. */ private MathTransform unique(final MathTransform tr) { return pool.unique(tr); }
/** * Returns the given value casted to a {@code Set} of elements of the given type. * It is caller responsibility to ensure that the cast is valid, as element type * is verified only when assertions are enabled. */ @SuppressWarnings("unchecked") private static <E> Set<E> cast(final Object value, final Class<E> type) { assert ((CheckedContainer<?>) value).getElementType() == type; return (Set<E>) value; }
/** * Returns the element at the given index. * * @param index the element index. * @return the value at the given index. * @throws IndexOutOfBoundsException if the given index is out of bounds. */ @Override public Integer get(final int index) throws IndexOutOfBoundsException { return getInt(index); }
/** * Creates a new factory. */ public DefaultNameFactory() { pool = new WeakHashSet<>(GenericName.class); }
/** * Returns the root node. This method returns the node specified at * {@linkplain #DefaultTreeTable(Node) construction time} or to the * last call of the {@link #setRoot(TreeTable.Node)} method. */ @Override public TreeTable.Node getRoot() { if (root == null) { root = new Node(this); } return root; }
/** * Returns the range at the given array index. The given index is relative to * the interval {@link #array}, which is twice the index of range elements. * * @param index the range index, from 0 inclusive to {@link #length} exclusive. */ final Range<E> getRange(final int index) { return newRange(getValue(index), getValue(index+1)); }
/** * Removes a single instance of the specified element from this set, if it is present * Null values are considered never present. * * @param element element to be removed from this set, if present. Can be {@code null}. * @return {@code true} if the set contained the specified element. */ @Override public synchronized boolean remove(final Object element) { return intern(element, REMOVE) != null; }
/** * Creates a new iterator wrapping the given iterator from {@link CacheEntries#entries}. */ Iter(final Iterator<Map.Entry<K,Object>> it) { this.it = it; advance(); }
/** * Returns the locale to use for code lists, international strings and exception messages. */ final Locale getDisplayLocale() { return getLocale(Locale.Category.DISPLAY); }
/** * Returns the frequency of the specified element in this set. * * @param element the element whose frequency is to be obtained. * @return the frequency of the given element, or {@code 0} if it does not occur in this set. */ public int frequency(final E element) { return signedFrequency(element) ^ order; }
/** * Returns an iterator over the elements in this set of ranges. * All elements are {@link Range} objects. */ @Override public Iterator<Range<E>> iterator() { return new Iter(length); }
/** * Returns the index of the first occurrence of the specified node in this list. * This method delegates to {@link #lastIndexOf(Object)} because the list is not * expected to contain duplicated values. * * @param node the node to search (can be {@code null}). * @return index of the given node, or -1 if not found. */ @Override public final int indexOf(final Object node) { return lastIndexOf(node); }
@Override public ObjectConverter<Entry<K,V>, Entry<SK,SV>> inverse() { if (inverse == null) { inverse = new DerivedMap<>(null, keyInverse, valueInverse); } return inverse; } }
/** * Returns an iterator over the elements in this set in frequency order. */ @Override public Iterator<E> iterator() { ensureSorted(); return new Iter(sorted, 0, sorted.length); }
/** * Returns a view of the portion of this set whose elements occur with a frequency strictly less than * {@code toElement} frequency. * * @param toElement high endpoint (exclusive) of the returned set. May be {@code null}. * @return a view of the portion of this set delimited by the given endpoint. */ @Override public SortedSet<E> headSet(final E toElement) { return new SubSet(false, null, true, toElement); }
/** * Returns {@code true} if this set contains the specified element. * Null values are considered never present. * * @param element object to be checked for containment in this set. Can be {@code null}. * @return {@code true} if this set contains the specified element. */ @Override public synchronized boolean contains(final Object element) { return intern(element, GET) != null; }
/** * Returns a view of the portion of this set whose elements occur with a frequency in the range of * {@code fromElement} frequency inclusive to {@code toElement} frequency exclusive. * * @param fromElement low endpoint (inclusive) of the returned set. May be {@code null}. * @param toElement high endpoint (exclusive) of the returned set. May be {@code null}. * @return a view of the portion of this set delimited by the given endpoints. */ @Override public SortedSet<E> subSet(final E fromElement, final E toElement) { return new SubSet(true, fromElement, true, toElement); }