📄 basetreesetimpl.java
字号:
} return result; } /** * Removes all elements in this Set. */ public void clear() { map.clear(); } /** * Returns this Set's comparator. * * @return the comparator, or null if the set uses natural ordering */ public Comparator comparator() { return map.comparator(); } /** * Returns true if this Set contains the supplied Object, false otherwise. * * @param obj the Object to check for * @return true if it is in the set * @throws ClassCastException if obj cannot be compared with objects * already in the set */ public boolean contains(Object obj) { return map.containsKey(obj); } /** * Returns the first (by order) element in this Set. * * @return the first element * @throws java.util.NoSuchElementException if the set is empty */ public Object first() { return map.firstKey(); } /** * Returns true if this Set has size 0, false otherwise. * * @return true if the set is empty */ public boolean isEmpty() { return map.isEmpty(); } /** * Returns in Iterator over the elements in this TreeSet, which traverses * in ascending order. * * @return an iterator */ public Iterator iterator() { return map.keySet().iterator(); } public Iterator _org_ozoneDB_internalIterator() { return ((OzoneSet) map.keySet())._org_ozoneDB_internalIterator(); } /** * Returns the last (by order) element in this Set. * * @return the last element * @throws java.util.NoSuchElementException if the set is empty */ public Object last() { return map.lastKey(); } /** * If the supplied Object is in this Set, it is removed, and true is * returned; otherwise, false is returned. * * @param obj the Object to remove from this Set * @return true if the set was modified * @throws ClassCastException if obj cannot be compared to set elements */ public boolean remove(Object obj) { return map.remove(obj) != null; } /** * Returns the number of elements in this Set * * @return the set size */ public int size() { return map.size(); } /** <p>Returns a <code>Collection</code> that contains the same entries as this * persistent one; it is (by nature of the client-server enviromnent) always * a 'deep' copy of this <code>OzoneCollection</code>. I.e. the contents of * this <code>OzoneCollection</code> instance are always copied to the client * by use of serialization.<br/> * Note that the difference of calling <code>iterator()</code> * compared to <code>getClientCollection().iterator()</code> is that in * the first case you go through the real collection on the server and in * the second case you go through a local copy on the client side.</p> * <p>Note that all subclasses of <code>OzoneCollection</code> (or * <code>OzoneMap</code>) have <code>getClientXxx()</code> member functions * that returns a collection of type <code>Xxx</code>; these simply return * a typecasted result value from <code>getClientCollection()</code> or * <code>getClientMap</code>.</p> * */ public Collection getClientCollection() { return getClientTreeSet(); } /** <p>Returns a <code>Set</code> that contains the same entries as this * persistent one; it is (by nature of the client-server enviromnent) always * a 'deep' copy of this <code>OzoneSet</code>. I.e. the contents of * this <code>OzoneSet</code> instance are always copied to the client * by use of serialization.</p> * <p>Note that the difference of calling <code>iterator()</code> * compared to <code>getClientSet().iterator()</code> is that in * the first case you go through the real collection on the server and in * the second case you go through a local copy on the client side.</p> * */ public Set getClientSet() { return getClientTreeSet(); } /** <p>Returns a <code>SortedSet</code> that contains the same entries as this * persistent one; it is (by nature of the client-server enviromnent) always * a 'deep' copy of this <code>OzoneSortedSet</code>. I.e. the contents of * this <code>OzoneSortedSet</code> instance are always copied to the client * by use of serialization.</p> * <p>Note that the difference of calling <code>iterator()</code> * compared to <code>getClientSortedSet().iterator()</code> is that in * the first case you go through the real collection on the server and in * the second case you go through a local copy on the client side.</p> * */ public SortedSet getClientSortedSet() { return getClientTreeSet(); } /** <p>Basically nothing more than a typecasted <code>HeadSet</code> method. * Because subsets are also <code>OzoneSortedSet</code>s, this method is * provided to do away with the need for a typecast.</p> * */ public OzoneSortedSet ozoneHeadSet(Object toElement) { return (OzoneSortedSet) headSet(toElement); } /** <p>Basically nothing more than a typecasted <code>SubSet</code> method. * Because subsets are also <code>OzoneSortedSet</code>s, this method is * provided to do away with the need for a typecast.</p> * */ public OzoneSortedSet ozoneSubSet(Object fromElement, Object toElement) { return (OzoneSortedSet) subSet(fromElement, toElement); } /** <p>Basically nothing more than a typecasted <code>TailSet</code> method.</p> * Because subsets are also <code>OzoneSortedSet</code>s, this method is * provided to do away with the need for a typecast.</p> * */ public OzoneSortedSet ozoneTailSet(Object toElement) { return (OzoneSortedSet) tailSet(toElement); } /** <p>Returns a <code>TreeSet</code> that contains the same entries as this * persistent one; it is (by nature of the client-server enviromnent) always * a 'deep' copy of this <code>OzoneTreeSet</code>. I.e. the contents of * this <code>OzoneTreeSet</code> instance are always copied to the client * by use of serialization.</p> * <p>Note that the difference of calling <code>iterator()</code> * compared to <code>getClientTreeSet().iterator()</code> is that in * the first case you go through the real collection on the server and in * the second case you go through a local copy on the client side.</p> * */ public TreeSet getClientTreeSet() { // do not make use of TreeSet(SortedSet) because that one calls our // iterator() and we don't want that, because we want to use an internal // iterator for speed and possible read-only db TreeSet result = new TreeSet(comparator()); for (Iterator i = _org_ozoneDB_internalIterator(); i.hasNext(); ) { result.add(i.next()); } return result; } /** Returns a string representation of the object. In general, the * <code>toString</code> method returns a string that * "textually represents" this object. The result should * be a concise but informative representation that is easy for a * person to read. * It is recommended that all subclasses override this method. * <p> * The <code>toString</code> method for class <code>Object</code> * returns a string consisting of the name of the class of which the * object is an instance, the at-sign character `<code>@</code>', and * the unsigned hexadecimal representation of the hash code of the * object. In other words, this method returns a string equal to the * value of: * <blockquote> * <pre> * getClass().getName() + '@' + Integer.toHexString(hashCode()) * </pre></blockquote> * * @return a string representation of the object. * */ public String toString() { return (map == null) ? "[]" : super.toString(); } protected abstract SortedMap newBackingMap(); protected abstract SortedMap newBackingMap(Comparator comparator);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -