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

📄 collections.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                throw new NullPointerException();            this.c = c;        }	public int size() 		    {return c.size();}	public boolean isEmpty() 	    {return c.isEmpty();}	public boolean contains(Object o)   {return c.contains(o);}	public Object[] toArray() 	    {return c.toArray();}	public Object[] toArray(Object[] a) {return c.toArray(a);}        public String toString()            {return c.toString();}	public Iterator iterator() {	    return new Iterator() {		Iterator i = c.iterator();		public boolean hasNext() {return i.hasNext();}		public Object next() 	 {return i.next();}		public void remove() {		    throw new UnsupportedOperationException();                }	    };        }	public boolean add(Object o){	    throw new UnsupportedOperationException();        }	public boolean remove(Object o) {	    throw new UnsupportedOperationException();        }	public boolean containsAll(Collection coll) {	    return c.containsAll(coll);        }	public boolean addAll(Collection coll) {	    throw new UnsupportedOperationException();        }	public boolean removeAll(Collection coll) {	    throw new UnsupportedOperationException();        }	public boolean retainAll(Collection coll) {	    throw new UnsupportedOperationException();        }	public void clear() {	    throw new UnsupportedOperationException();        }    }    /**     * Returns an unmodifiable view of the specified set.  This method allows     * modules to provide users with "read-only" access to internal sets.     * Query operations on the returned set "read through" to the specified     * set, and attempts to modify the returned set, whether direct or via its     * iterator, result in an <tt>UnsupportedOperationException</tt>.<p>     *     * The returned set will be serializable if the specified set     * is serializable.      *     * @param  s the set for which an unmodifiable view is to be returned.     * @return an unmodifiable view of the specified set.     */    public static Set unmodifiableSet(Set s) {	return new UnmodifiableSet(s);    }    /**     * @serial include     */    static class UnmodifiableSet extends UnmodifiableCollection    				 implements Set, Serializable {	UnmodifiableSet(Set s) 		{super(s);}	public boolean equals(Object o) {return c.equals(o);}	public int hashCode() 		{return c.hashCode();}    }    /**     * Returns an unmodifiable view of the specified sorted set.  This method     * allows modules to provide users with "read-only" access to internal     * sorted sets.  Query operations on the returned sorted set "read     * through" to the specified sorted set.  Attempts to modify the returned     * sorted set, whether direct, via its iterator, or via its     * <tt>subSet</tt>, <tt>headSet</tt>, or <tt>tailSet</tt> views, result in     * an <tt>UnsupportedOperationException</tt>.<p>     *     * The returned sorted set will be serializable if the specified sorted set     * is serializable.      *     * @param s the sorted set for which an unmodifiable view is to be     *        returned.      * @return an unmodifiable view of the specified sorted set.     */    public static SortedSet unmodifiableSortedSet(SortedSet s) {	return new UnmodifiableSortedSet(s);    }    /**     * @serial include     */    static class UnmodifiableSortedSet extends UnmodifiableSet    				 implements SortedSet, Serializable {        private SortedSet ss;	UnmodifiableSortedSet(SortedSet s) {super(s); ss = s;}        public Comparator comparator()     {return ss.comparator();}        public SortedSet subSet(Object fromElement, Object toElement) {            return new UnmodifiableSortedSet(ss.subSet(fromElement,toElement));        }        public SortedSet headSet(Object toElement) {            return new UnmodifiableSortedSet(ss.headSet(toElement));        }        public SortedSet tailSet(Object fromElement) {            return new UnmodifiableSortedSet(ss.tailSet(fromElement));        }        public Object first() 	           {return ss.first();}        public Object last()  	           {return ss.last();}    }    /**     * Returns an unmodifiable view of the specified list.  This method allows     * modules to provide users with "read-only" access to internal     * lists.  Query operations on the returned list "read through" to the     * specified list, and attempts to modify the returned list, whether     * direct or via its iterator, result in an     * <tt>UnsupportedOperationException</tt>.<p>     *     * The returned list will be serializable if the specified list     * is serializable. Similarly, the returned list will implement     * {@link RandomAccess} if the specified list does.     * the      *     * @param  list the list for which an unmodifiable view is to be returned.     * @return an unmodifiable view of the specified list.     */    public static List unmodifiableList(List list) {	return (list instanceof RandomAccess ?                new UnmodifiableRandomAccessList(list) :                new UnmodifiableList(list));    }    /**     * @serial include     */    static class UnmodifiableList extends UnmodifiableCollection    				  implements List {        static final long serialVersionUID = -283967356065247728L;	List list;	UnmodifiableList(List list) {	    super(list);	    this.list = list;	}	public boolean equals(Object o) {return list.equals(o);}	public int hashCode() 		{return list.hashCode();}	public Object get(int index) {return list.get(index);}	public Object set(int index, Object element) {	    throw new UnsupportedOperationException();        }	public void add(int index, Object element) {	    throw new UnsupportedOperationException();        }	public Object remove(int index) {	    throw new UnsupportedOperationException();        }	public int indexOf(Object o)            {return list.indexOf(o);}	public int lastIndexOf(Object o)        {return list.lastIndexOf(o);}	public boolean addAll(int index, Collection c) {	    throw new UnsupportedOperationException();        }	public ListIterator listIterator() 	{return listIterator(0);}	public ListIterator listIterator(final int index) {	    return new ListIterator() {		ListIterator i = list.listIterator(index);		public boolean hasNext()     {return i.hasNext();}		public Object next()         {return i.next();}		public boolean hasPrevious() {return i.hasPrevious();}		public Object previous()     {return i.previous();}		public int nextIndex()       {return i.nextIndex();}		public int previousIndex()   {return i.previousIndex();}		public void remove() {		    throw new UnsupportedOperationException();                }		public void set(Object o) {		    throw new UnsupportedOperationException();                }		public void add(Object o) {		    throw new UnsupportedOperationException();                }	    };	}	public List subList(int fromIndex, int toIndex) {            return new UnmodifiableList(list.subList(fromIndex, toIndex));        }        /**         * UnmodifiableRandomAccessList instances are serialized as         * UnmodifiableList instances to allow them to be deserialized         * in pre-1.4 JREs (which do not have UnmodifiableRandomAccessList).         * This method inverts the transformation.  As a beneficial         * side-effect, it also grafts the RandomAccess marker onto         * UnmodifiableList instances that were serialized in pre-1.4 JREs.         *         * Note: Unfortunately, UnmodifiableRandomAccessList instances         * serialized in 1.4.1 and deserialized in 1.4 will become         * UnmodifiableList instances, as this method was missing in 1.4.         */        private Object readResolve() {            return (list instanceof RandomAccess ?                    new UnmodifiableRandomAccessList(list) : this);        }    }    /**     * @serial include     */    static class UnmodifiableRandomAccessList extends UnmodifiableList                                              implements RandomAccess    {        UnmodifiableRandomAccessList(List list) {            super(list);        }	public List subList(int fromIndex, int toIndex) {            return new UnmodifiableRandomAccessList(                list.subList(fromIndex, toIndex));        }        private static final long serialVersionUID = -2542308836966382001L;        /**         * Allows instances to be deserialized in pre-1.4 JREs (which do         * not have UnmodifiableRandomAccessList).  UnmodifiableList has         * a readResolve method that inverts this transformation upon         * deserialization.         */        private Object writeReplace() {            return new UnmodifiableList(list);        }    }    /**     * Returns an unmodifiable view of the specified map.  This method     * allows modules to provide users with "read-only" access to internal     * maps.  Query operations on the returned map "read through"     * to the specified map, and attempts to modify the returned     * map, whether direct or via its collection views, result in an     * <tt>UnsupportedOperationException</tt>.<p>     *     * The returned map will be serializable if the specified map     * is serializable.      *     * @param  m the map for which an unmodifiable view is to be returned.     * @return an unmodifiable view of the specified map.     */    public static Map unmodifiableMap(Map m) {	return new UnmodifiableMap(m);    }    /**     * @serial include     */    private static class UnmodifiableMap implements Map, Serializable {	// use serialVersionUID from JDK 1.2.2 for interoperability	private static final long serialVersionUID = -1034234728574286014L;	private final Map m;	UnmodifiableMap(Map m) {            if (m==null)                throw new NullPointerException();            this.m = m;        }	public int size() 		         {return m.size();}	public boolean isEmpty() 	         {return m.isEmpty();}	public boolean containsKey(Object key)   {return m.containsKey(key);}	public boolean containsValue(Object val) {return m.containsValue(val);}	public Object get(Object key) 	         {return m.get(key);}	public Object put(Object key, Object value) {	    throw new UnsupportedOperationException();        }	public Object remove(Object key) {	    throw new UnsupportedOperationException();        }	public void putAll(Map t) {	    throw new UnsupportedOperationException();        }	public void clear() {	    throw new UnsupportedOperationException();        }	private transient Set keySet = null;	private transient Set entrySet = null;	private transient Collection values = null;	public Set keySet() {	    if (keySet==null)		keySet = unmodifiableSet(m.keySet());	    return keySet;	}	public Set entrySet() {	    if (entrySet==null)		entrySet = new UnmodifiableEntrySet(m.entrySet());	    return entrySet;	}	public Collection values() {	    if (values==null)		values = unmodifiableCollection(m.values());	    return values;	}	public boolean equals(Object o) {return m.equals(o);}	public int hashCode()           {return m.hashCode();}        public String toString()        {return m.toString();}        /**         * We need this class in addition to UnmodifiableSet as         * Map.Entries themselves permit modification of the backing Map         * via their setValue operation.  This class is subtle: there are         * many possible attacks that must be thwarted.         *

⌨️ 快捷键说明

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