Java 类org.apache.commons.collections.keyvalue.AbstractMapEntry 实例源码

项目:mondrian    文件:Util.java   
public Set<Entry<K, V>> entrySet() {
    return new AbstractSet<Entry<K, V>>() {
        public Iterator<Entry<K, V>>
            iterator()
        {
            return new Iterator<Entry<K, V>>() {
                private int pt = -1;
                public void remove() {
                    throw new UnsupportedOperationException();
                }
                @SuppressWarnings("unchecked")
                public Entry<K, V> next() {
                    return new AbstractMapEntry(
                        list.get(++pt), null) {};
                }
                public boolean hasNext() {
                    return pt < list.size();
                }
            };
        }
        public int size() {
            return list.size();
        }
        public boolean contains(Object o) {
            if (o instanceof Entry) {
                if (list.contains(((Entry) o).getKey())) {
                    return true;
                }
            }
            return false;
        }
    };
}