FileDocCategorySizeDatePackage
CircularIdentityList.javaAPI DocJava SE 5 API3452Fri Aug 26 14:54:44 BST 2005com.sun.java.swing.plaf.gtk

CircularIdentityList

public class CircularIdentityList extends Object implements Cloneable
An circular linked list like data structure that uses identity for equality testing.
version
1.5, 12/19/03
author
Scott Violet

Fields Summary
private Property
property
Constructors Summary
Methods Summary
public synchronized java.lang.Objectclone()

        try {
            CircularIdentityList list = (CircularIdentityList)super.clone();

            if (property != null) {
                list.property = (Property)property.clone();

                Property last = list.property;

                while (last.next != null && last.next != property) {
                    last.next = (Property)last.next.clone();
                    last = last.next;
                }
                last.next = list.property;
            }
            return list;
        } catch (CloneNotSupportedException cnse) {
        }
        return null;
    
public synchronized java.lang.Objectget()
Returns the value currently being referenced.

        if (property == null) {
            return null;
        }
        return property.value;
    
public synchronized java.lang.Objectget(java.lang.Object key)
Returns the value for a specific key.

        if (property == null) {
            return null;
        }
        Property p = property;

        do {
            if (p.key == key) {
                return p.value;
            }
            p = p.next;
        } while (p != property && p != null);
        return null;
    
public synchronized java.lang.Objectnext()
Advanced the list returning the next key. This will only return null if the list is empty.

        if (property == null) {
            return null;
        }
        if (property.next == null) {
            return property.key;
        }
        property = property.next;
        return property.key;
    
public synchronized voidset(java.lang.Object key, java.lang.Object value)
Sets a particular value.

        if (property == null) {
            property = new Property(key, value, null);
        }
        else {
            Property p = property;
            Property last = p;

            do {
                if (p.key == key) {
                    p.value = value;
                    property = p;
                    return;
                }
                last = p;
                p = p.next;
            } while (p != property && p != null);
            // not defined
            if (value != null) {
                if (p == null) {
                    // Only one element
                    p = property;
                }
                property = new Property(key, value, p);
                last.next = property;
            }
        }