Ejemplo n.º 1
0
        // APIs maintained from previous version of SequencedHashMap for backwards
        // compatibility

        /**
         * Creates a shallow copy of this object, preserving the internal structure
         * by copying only references.  The keys and values themselves are not
         * <code>clone()</code>'d.  The cloned object maintains the same sequence.
         *
         * @return A clone of this instance.
         *
         * @throws CloneNotSupportedException if clone is not supported by a
         * subclass.
         */
        public Object clone()
        {//throws CloneNotSupportedException {
            // yes, calling super.clone() silly since we're just blowing away all
            // the stuff that super might be doing anyway, but for motivations on
            // this, see:
            // http://www.javaworld.com/javaworld/jw-01-1999/jw-01-object.html
            SequencedHashMap map = (SequencedHashMap)base.MemberwiseClone();

            // create new, empty sentinel
            map.sentinel = createSentinel();

            // create a new, empty entry map
            // note: this does not preserve the initial capacity and load factor.
            map.entries = new java.util.HashMap <Object, Object>();

            // add all the mappings
            map.putAll(this);

            // Note: We cannot just clone the hashmap and sentinel because we must
            // duplicate our internal structures.  Cloning those two will not clone all
            // the other entries they reference, and so the cloned hash map will not be
            // able to maintain internal consistency because there are two objects with
            // the same entries.  See discussion in the Entry implementation on why we
            // cannot implement a clone of the Entry (and thus why we need to recreate
            // everything).

            return(map);
        }
Ejemplo n.º 2
0
            /**
             *  Construct an iterator over the sequenced elements in the order in which
             *  they were added.  The {@link #next()} method returns the type specified
             *  by <code>returnType</code> which must be either {@link #KEY}, {@link
             *  #VALUE}, or {@link #ENTRY}.
             */
            public OrderedIterator(uint returnType, SequencedHashMap shm)
            {
                pos = root.sentinel;
                expectedModCount = root.modCount;
                this.root        = shm;
                //// Since this is a private inner class, nothing else should have
                //// access to the constructor.  Since we know the rest of the outer
                //// class uses the iterator correctly, we can leave of the following
                //// check:
                //if(returnType >= 0 && returnType <= 2) {
                //  throw new java.lang.IllegalArgumentException("Invalid iterator type");
                //}

                // Set the "removed" bit so that the iterator starts in a state where
                // "next" must be called before "remove" will succeed.
                this.returnType = returnType | REMOVED_MASK;
            }
Ejemplo n.º 3
0
 public IAC_VALUES(SequencedHashMap shm)
 {
     root = shm;
 }
Ejemplo n.º 4
0
 public IAC_ENTRYSET(SequencedHashMap shm)
 {
     root = shm;
 }
Ejemplo n.º 5
0
 public IAC_KeySet(SequencedHashMap shm)
 {
     root = shm;
 }