⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fulltreesetimpl.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// This file is// Copyright (C) 2002-@year@ Leo Mekenkamp. All rights reserved.// $Id: FullTreeSetImpl.java,v 1.10 2003/11/27 15:55:11 leomekenkamp Exp $package org.ozoneDB.collections;import java.util.Collection;import java.util.Comparator;import java.util.SortedMap;import java.util.SortedSet;/** * <p>Note that calling <code>iterator()</code> results in the creation of * an ozone object and thus in a write-action for the db.</p> * * @author <a href="mailto:ozoneATmekenkampD0Tcom">Leo Mekenkamp (mind the anti-sp@m)</a> */public class FullTreeSetImpl extends BaseTreeSetImpl implements FullTreeSet {    private static final long serialVersionUID = 1L;    /**     * Construct a new TreeSet whose backing TreeMap using the "natural"     * ordering of keys. Elements that are not mutually comparable will cause     * ClassCastExceptions down the road.     *     * @see Comparable     */    public FullTreeSetImpl() {    }    /**     * Construct a new TreeSet whose backing TreeMap uses the supplied     * Comparator. Elements that are not mutually comparable will cause     * ClassCastExceptions down the road.     *     * @param comparator the Comparator this Set will use     */    public FullTreeSetImpl(Comparator comparator) {        super(comparator);    }    /**     * Construct a new TreeSet whose backing TreeMap uses the "natural"     * orering of the keys and which contains all of the elements in the     * supplied Collection. This runs in n*log(n) time.     *     * @param collection the new Set will be initialized with all     *        of the elements in this Collection     * @throws ClassCastException if the elements of the collection are not     *         comparable     * @throws NullPointerException if the collection is null     * @see Comparable     */    public FullTreeSetImpl(Collection collection) {        super(collection);    }    /**     * Construct a new TreeSet, using the same key ordering as the supplied     * SortedSet and containing all of the elements in the supplied SortedSet.     * This constructor runs in linear time.     *     * @param sortedSet the new TreeSet will use this SortedSet's comparator     *        and will initialize itself with all its elements     * @throws NullPointerException if sortedSet is null     */    public FullTreeSetImpl(SortedSet sortedSet) {        super(sortedSet);    }    /**     * <P>DO NOT USE THIS CONSTRUCTOR YOURSELF, NOR USE EQUIVALENT CREATE     * METHOD FROM FACTORY.</p>     * <p>This constructor is used to implement the subSet() calls around     * a backing TreeMap.SubMap.</p>     *     * @param backingMap the submap     */    public FullTreeSetImpl(SortedMap backingMap, DoNotUse_SeeJavadoc x) {        super(0);        map = backingMap;    }    /**     * Returns a shallow copy of this Set. The elements are not cloned.     *     * @return the cloned set     */    public Object clone() {        BaseTreeSet copy = null;        try {// TODO: replace when FakeFactoryGenerator is ready//            copy = FullTreeMapImplFactory.getDefault().create(self());            copy = (BaseTreeSet) database().createObject(FullTreeSetImpl.class, new Class[] {FullTreeSetImpl.class}, new Object[] {self()});        }        catch (Exception e) {            throw new RuntimeException(e);        }        return copy;    }    /**     * Returns a view of this Set including all elements less than     * <code>to</code>. The returned set is backed by the original, so changes     * in one appear in the other. The subset will throw an     * {@link IllegalArgumentException} for any attempt to access or add an     * element beyond the specified cutoff. The returned set does not include     * the endpoint; if you want inclusion, pass the successor element.     *     * @param to the (exclusive) cutoff point     * @return a view of the set less than the cutoff     * @throws ClassCastException if <code>to</code> is not compatible with     *         the comparator (or is not Comparable, for natural ordering)     * @throws NullPointerException if to is null, but the comparator does not     *         tolerate null elements     */    public SortedSet headSet(Object to) {// TODO: replace when FakeFactoryGenerator is ready//            return FullTreeSetImplFactory.getDefault().create(map.headMap(to), null);        SortedMap headMap = map.headMap(to);        SortedSet result = (FullTreeSet) database().createObject(FullTreeSetImpl.class,                new Class[] {SortedMap.class, DoNotUse_SeeJavadoc.class},                new Object[] {headMap, null});        return result;    }    /**     * Returns a view of this Set including all elements greater or equal to     * <code>from</code> and less than <code>to</code> (a half-open interval).     * The returned set is backed by the original, so changes in one appear in     * the other. The subset will throw an {@link IllegalArgumentException}     * for any attempt to access or add an element beyond the specified cutoffs.     * The returned set includes the low endpoint but not the high; if you want     * to reverse this behavior on either end, pass in the successor element.     *     * @param from the (inclusive) low cutoff point     * @param to the (exclusive) high cutoff point     * @return a view of the set between the cutoffs     * @throws ClassCastException if either cutoff is not compatible with     *         the comparator (or is not Comparable, for natural ordering)     * @throws NullPointerException if from or to is null, but the comparator     *         does not tolerate null elements     * @throws IllegalArgumentException if from is greater than to     */    public SortedSet subSet(Object from, Object to) {// TODO: replace when FakeFactoryGenerator is ready//            return NodeTreeSetImplFactory.getDefault().create(map.subMap(from, to), null);        SortedMap subMap = map.subMap(from, to);        return (FullTreeSet) database().createObject(                FullTreeSetImpl.class,                new Class[] {SortedMap.class, DoNotUse_SeeJavadoc.class},                new Object[] {subMap, null});    }    /**     * Returns a view of this Set including all elements greater or equal to     * <code>from</code>. The returned set is backed by the original, so     * changes in one appear in the other. The subset will throw an     * {@link IllegalArgumentException} for any attempt to access or add an     * element beyond the specified cutoff. The returned set includes the     * endpoint; if you want to exclude it, pass in the successor element.     *     * @param from the (inclusive) low cutoff point     * @return a view of the set above the cutoff     * @throws ClassCastException if <code>from</code> is not compatible with     *         the comparator (or is not Comparable, for natural ordering)     * @throws NullPointerException if from is null, but the comparator     *         does not tolerate null elements     */    public SortedSet tailSet(Object from) {// TODO: replace when FakeFactoryGenerator is ready//            return NodeTreeSetImplFactory.getDefault().create(map.tailMap(from), null);        SortedMap tailMap = map.tailMap(from);        return (FullTreeSet) database().createObject(                FullTreeSetImpl.class,                new Class[] {SortedMap.class, DoNotUse_SeeJavadoc.class},                new Object[] {tailMap, null}        );    }    protected SortedMap newBackingMap() {// TODO: replace when FakeFactoryGenerator is ready//        map = FullTreeMapImplFactory.getDefault.create();        return (FullTreeMap) database().createObject(FullTreeMapImpl.class.getName());    }    protected SortedMap newBackingMap(Comparator comparator) {// TODO: replace when FakeFactoryGenerator is ready//        map = FullTreeMapImplFactory.getDefault.create(comparator);        return (FullTreeMap) database().createObject(FullTreeMapImpl.class.getName(),                Comparator.class.getName(), new Object[] {comparator});    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -