1 |
|
/* |
2 |
< |
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. |
2 |
> |
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved. |
3 |
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
|
* |
5 |
|
* This code is free software; you can redistribute it and/or modify it |
18 |
|
* 2 along with this work; if not, write to the Free Software Foundation, |
19 |
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
* |
21 |
< |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
22 |
< |
* CA 95054 USA or visit www.sun.com if you need additional information or |
23 |
< |
* have any questions. |
21 |
> |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
> |
* or visit www.oracle.com if you need additional information or have any |
23 |
> |
* questions. |
24 |
|
*/ |
25 |
|
|
26 |
|
package java.util; |
823 |
|
i -= size; |
824 |
|
displaced = list.set(i, displaced); |
825 |
|
nMoved ++; |
826 |
< |
} while(i != cycleStart); |
826 |
> |
} while (i != cycleStart); |
827 |
|
} |
828 |
|
} |
829 |
|
|
1562 |
|
* <pre> |
1563 |
|
* Collection c = Collections.synchronizedCollection(myCollection); |
1564 |
|
* ... |
1565 |
< |
* synchronized(c) { |
1565 |
> |
* synchronized (c) { |
1566 |
|
* Iterator i = c.iterator(); // Must be in the synchronized block |
1567 |
|
* while (i.hasNext()) |
1568 |
|
* foo(i.next()); |
1611 |
|
} |
1612 |
|
|
1613 |
|
public int size() { |
1614 |
< |
synchronized(mutex) {return c.size();} |
1614 |
> |
synchronized (mutex) {return c.size();} |
1615 |
|
} |
1616 |
|
public boolean isEmpty() { |
1617 |
< |
synchronized(mutex) {return c.isEmpty();} |
1617 |
> |
synchronized (mutex) {return c.isEmpty();} |
1618 |
|
} |
1619 |
|
public boolean contains(Object o) { |
1620 |
< |
synchronized(mutex) {return c.contains(o);} |
1620 |
> |
synchronized (mutex) {return c.contains(o);} |
1621 |
|
} |
1622 |
|
public Object[] toArray() { |
1623 |
< |
synchronized(mutex) {return c.toArray();} |
1623 |
> |
synchronized (mutex) {return c.toArray();} |
1624 |
|
} |
1625 |
|
public <T> T[] toArray(T[] a) { |
1626 |
< |
synchronized(mutex) {return c.toArray(a);} |
1626 |
> |
synchronized (mutex) {return c.toArray(a);} |
1627 |
|
} |
1628 |
|
|
1629 |
|
public Iterator<E> iterator() { |
1631 |
|
} |
1632 |
|
|
1633 |
|
public boolean add(E e) { |
1634 |
< |
synchronized(mutex) {return c.add(e);} |
1634 |
> |
synchronized (mutex) {return c.add(e);} |
1635 |
|
} |
1636 |
|
public boolean remove(Object o) { |
1637 |
< |
synchronized(mutex) {return c.remove(o);} |
1637 |
> |
synchronized (mutex) {return c.remove(o);} |
1638 |
|
} |
1639 |
|
|
1640 |
|
public boolean containsAll(Collection<?> coll) { |
1641 |
< |
synchronized(mutex) {return c.containsAll(coll);} |
1641 |
> |
synchronized (mutex) {return c.containsAll(coll);} |
1642 |
|
} |
1643 |
|
public boolean addAll(Collection<? extends E> coll) { |
1644 |
< |
synchronized(mutex) {return c.addAll(coll);} |
1644 |
> |
synchronized (mutex) {return c.addAll(coll);} |
1645 |
|
} |
1646 |
|
public boolean removeAll(Collection<?> coll) { |
1647 |
< |
synchronized(mutex) {return c.removeAll(coll);} |
1647 |
> |
synchronized (mutex) {return c.removeAll(coll);} |
1648 |
|
} |
1649 |
|
public boolean retainAll(Collection<?> coll) { |
1650 |
< |
synchronized(mutex) {return c.retainAll(coll);} |
1650 |
> |
synchronized (mutex) {return c.retainAll(coll);} |
1651 |
|
} |
1652 |
|
public void clear() { |
1653 |
< |
synchronized(mutex) {c.clear();} |
1653 |
> |
synchronized (mutex) {c.clear();} |
1654 |
|
} |
1655 |
|
public String toString() { |
1656 |
< |
synchronized(mutex) {return c.toString();} |
1656 |
> |
synchronized (mutex) {return c.toString();} |
1657 |
|
} |
1658 |
|
private void writeObject(ObjectOutputStream s) throws IOException { |
1659 |
< |
synchronized(mutex) {s.defaultWriteObject();} |
1659 |
> |
synchronized (mutex) {s.defaultWriteObject();} |
1660 |
|
} |
1661 |
|
} |
1662 |
|
|
1671 |
|
* <pre> |
1672 |
|
* Set s = Collections.synchronizedSet(new HashSet()); |
1673 |
|
* ... |
1674 |
< |
* synchronized(s) { |
1674 |
> |
* synchronized (s) { |
1675 |
|
* Iterator i = s.iterator(); // Must be in the synchronized block |
1676 |
|
* while (i.hasNext()) |
1677 |
|
* foo(i.next()); |
1709 |
|
} |
1710 |
|
|
1711 |
|
public boolean equals(Object o) { |
1712 |
< |
synchronized(mutex) {return c.equals(o);} |
1712 |
> |
synchronized (mutex) {return c.equals(o);} |
1713 |
|
} |
1714 |
|
public int hashCode() { |
1715 |
< |
synchronized(mutex) {return c.hashCode();} |
1715 |
> |
synchronized (mutex) {return c.hashCode();} |
1716 |
|
} |
1717 |
|
} |
1718 |
|
|
1728 |
|
* <pre> |
1729 |
|
* SortedSet s = Collections.synchronizedSortedSet(new TreeSet()); |
1730 |
|
* ... |
1731 |
< |
* synchronized(s) { |
1731 |
> |
* synchronized (s) { |
1732 |
|
* Iterator i = s.iterator(); // Must be in the synchronized block |
1733 |
|
* while (i.hasNext()) |
1734 |
|
* foo(i.next()); |
1739 |
|
* SortedSet s = Collections.synchronizedSortedSet(new TreeSet()); |
1740 |
|
* SortedSet s2 = s.headSet(foo); |
1741 |
|
* ... |
1742 |
< |
* synchronized(s) { // Note: s, not s2!!! |
1742 |
> |
* synchronized (s) { // Note: s, not s2!!! |
1743 |
|
* Iterator i = s2.iterator(); // Must be in the synchronized block |
1744 |
|
* while (i.hasNext()) |
1745 |
|
* foo(i.next()); |
1778 |
|
} |
1779 |
|
|
1780 |
|
public Comparator<? super E> comparator() { |
1781 |
< |
synchronized(mutex) {return ss.comparator();} |
1781 |
> |
synchronized (mutex) {return ss.comparator();} |
1782 |
|
} |
1783 |
|
|
1784 |
|
public SortedSet<E> subSet(E fromElement, E toElement) { |
1785 |
< |
synchronized(mutex) { |
1785 |
> |
synchronized (mutex) { |
1786 |
|
return new SynchronizedSortedSet<E>( |
1787 |
|
ss.subSet(fromElement, toElement), mutex); |
1788 |
|
} |
1789 |
|
} |
1790 |
|
public SortedSet<E> headSet(E toElement) { |
1791 |
< |
synchronized(mutex) { |
1791 |
> |
synchronized (mutex) { |
1792 |
|
return new SynchronizedSortedSet<E>(ss.headSet(toElement), mutex); |
1793 |
|
} |
1794 |
|
} |
1795 |
|
public SortedSet<E> tailSet(E fromElement) { |
1796 |
< |
synchronized(mutex) { |
1796 |
> |
synchronized (mutex) { |
1797 |
|
return new SynchronizedSortedSet<E>(ss.tailSet(fromElement),mutex); |
1798 |
|
} |
1799 |
|
} |
1800 |
|
|
1801 |
|
public E first() { |
1802 |
< |
synchronized(mutex) {return ss.first();} |
1802 |
> |
synchronized (mutex) {return ss.first();} |
1803 |
|
} |
1804 |
|
public E last() { |
1805 |
< |
synchronized(mutex) {return ss.last();} |
1805 |
> |
synchronized (mutex) {return ss.last();} |
1806 |
|
} |
1807 |
|
} |
1808 |
|
|
1817 |
|
* <pre> |
1818 |
|
* List list = Collections.synchronizedList(new ArrayList()); |
1819 |
|
* ... |
1820 |
< |
* synchronized(list) { |
1820 |
> |
* synchronized (list) { |
1821 |
|
* Iterator i = list.iterator(); // Must be in synchronized block |
1822 |
|
* while (i.hasNext()) |
1823 |
|
* foo(i.next()); |
1863 |
|
} |
1864 |
|
|
1865 |
|
public boolean equals(Object o) { |
1866 |
< |
synchronized(mutex) {return list.equals(o);} |
1866 |
> |
synchronized (mutex) {return list.equals(o);} |
1867 |
|
} |
1868 |
|
public int hashCode() { |
1869 |
< |
synchronized(mutex) {return list.hashCode();} |
1869 |
> |
synchronized (mutex) {return list.hashCode();} |
1870 |
|
} |
1871 |
|
|
1872 |
|
public E get(int index) { |
1873 |
< |
synchronized(mutex) {return list.get(index);} |
1873 |
> |
synchronized (mutex) {return list.get(index);} |
1874 |
|
} |
1875 |
|
public E set(int index, E element) { |
1876 |
< |
synchronized(mutex) {return list.set(index, element);} |
1876 |
> |
synchronized (mutex) {return list.set(index, element);} |
1877 |
|
} |
1878 |
|
public void add(int index, E element) { |
1879 |
< |
synchronized(mutex) {list.add(index, element);} |
1879 |
> |
synchronized (mutex) {list.add(index, element);} |
1880 |
|
} |
1881 |
|
public E remove(int index) { |
1882 |
< |
synchronized(mutex) {return list.remove(index);} |
1882 |
> |
synchronized (mutex) {return list.remove(index);} |
1883 |
|
} |
1884 |
|
|
1885 |
|
public int indexOf(Object o) { |
1886 |
< |
synchronized(mutex) {return list.indexOf(o);} |
1886 |
> |
synchronized (mutex) {return list.indexOf(o);} |
1887 |
|
} |
1888 |
|
public int lastIndexOf(Object o) { |
1889 |
< |
synchronized(mutex) {return list.lastIndexOf(o);} |
1889 |
> |
synchronized (mutex) {return list.lastIndexOf(o);} |
1890 |
|
} |
1891 |
|
|
1892 |
|
public boolean addAll(int index, Collection<? extends E> c) { |
1893 |
< |
synchronized(mutex) {return list.addAll(index, c);} |
1893 |
> |
synchronized (mutex) {return list.addAll(index, c);} |
1894 |
|
} |
1895 |
|
|
1896 |
|
public ListIterator<E> listIterator() { |
1902 |
|
} |
1903 |
|
|
1904 |
|
public List<E> subList(int fromIndex, int toIndex) { |
1905 |
< |
synchronized(mutex) { |
1905 |
> |
synchronized (mutex) { |
1906 |
|
return new SynchronizedList<E>(list.subList(fromIndex, toIndex), |
1907 |
|
mutex); |
1908 |
|
} |
1943 |
|
} |
1944 |
|
|
1945 |
|
public List<E> subList(int fromIndex, int toIndex) { |
1946 |
< |
synchronized(mutex) { |
1946 |
> |
synchronized (mutex) { |
1947 |
|
return new SynchronizedRandomAccessList<E>( |
1948 |
|
list.subList(fromIndex, toIndex), mutex); |
1949 |
|
} |
1975 |
|
* ... |
1976 |
|
* Set s = m.keySet(); // Needn't be in synchronized block |
1977 |
|
* ... |
1978 |
< |
* synchronized(m) { // Synchronizing on m, not s! |
1978 |
> |
* synchronized (m) { // Synchronizing on m, not s! |
1979 |
|
* Iterator i = s.iterator(); // Must be in synchronized block |
1980 |
|
* while (i.hasNext()) |
1981 |
|
* foo(i.next()); |
2016 |
|
} |
2017 |
|
|
2018 |
|
public int size() { |
2019 |
< |
synchronized(mutex) {return m.size();} |
2019 |
> |
synchronized (mutex) {return m.size();} |
2020 |
|
} |
2021 |
|
public boolean isEmpty() { |
2022 |
< |
synchronized(mutex) {return m.isEmpty();} |
2022 |
> |
synchronized (mutex) {return m.isEmpty();} |
2023 |
|
} |
2024 |
|
public boolean containsKey(Object key) { |
2025 |
< |
synchronized(mutex) {return m.containsKey(key);} |
2025 |
> |
synchronized (mutex) {return m.containsKey(key);} |
2026 |
|
} |
2027 |
|
public boolean containsValue(Object value) { |
2028 |
< |
synchronized(mutex) {return m.containsValue(value);} |
2028 |
> |
synchronized (mutex) {return m.containsValue(value);} |
2029 |
|
} |
2030 |
|
public V get(Object key) { |
2031 |
< |
synchronized(mutex) {return m.get(key);} |
2031 |
> |
synchronized (mutex) {return m.get(key);} |
2032 |
|
} |
2033 |
|
|
2034 |
|
public V put(K key, V value) { |
2035 |
< |
synchronized(mutex) {return m.put(key, value);} |
2035 |
> |
synchronized (mutex) {return m.put(key, value);} |
2036 |
|
} |
2037 |
|
public V remove(Object key) { |
2038 |
< |
synchronized(mutex) {return m.remove(key);} |
2038 |
> |
synchronized (mutex) {return m.remove(key);} |
2039 |
|
} |
2040 |
|
public void putAll(Map<? extends K, ? extends V> map) { |
2041 |
< |
synchronized(mutex) {m.putAll(map);} |
2041 |
> |
synchronized (mutex) {m.putAll(map);} |
2042 |
|
} |
2043 |
|
public void clear() { |
2044 |
< |
synchronized(mutex) {m.clear();} |
2044 |
> |
synchronized (mutex) {m.clear();} |
2045 |
|
} |
2046 |
|
|
2047 |
|
private transient Set<K> keySet = null; |
2049 |
|
private transient Collection<V> values = null; |
2050 |
|
|
2051 |
|
public Set<K> keySet() { |
2052 |
< |
synchronized(mutex) { |
2052 |
> |
synchronized (mutex) { |
2053 |
|
if (keySet==null) |
2054 |
|
keySet = new SynchronizedSet<K>(m.keySet(), mutex); |
2055 |
|
return keySet; |
2057 |
|
} |
2058 |
|
|
2059 |
|
public Set<Map.Entry<K,V>> entrySet() { |
2060 |
< |
synchronized(mutex) { |
2060 |
> |
synchronized (mutex) { |
2061 |
|
if (entrySet==null) |
2062 |
|
entrySet = new SynchronizedSet<Map.Entry<K,V>>(m.entrySet(), mutex); |
2063 |
|
return entrySet; |
2065 |
|
} |
2066 |
|
|
2067 |
|
public Collection<V> values() { |
2068 |
< |
synchronized(mutex) { |
2068 |
> |
synchronized (mutex) { |
2069 |
|
if (values==null) |
2070 |
|
values = new SynchronizedCollection<V>(m.values(), mutex); |
2071 |
|
return values; |
2073 |
|
} |
2074 |
|
|
2075 |
|
public boolean equals(Object o) { |
2076 |
< |
synchronized(mutex) {return m.equals(o);} |
2076 |
> |
synchronized (mutex) {return m.equals(o);} |
2077 |
|
} |
2078 |
|
public int hashCode() { |
2079 |
< |
synchronized(mutex) {return m.hashCode();} |
2079 |
> |
synchronized (mutex) {return m.hashCode();} |
2080 |
|
} |
2081 |
|
public String toString() { |
2082 |
< |
synchronized(mutex) {return m.toString();} |
2082 |
> |
synchronized (mutex) {return m.toString();} |
2083 |
|
} |
2084 |
|
private void writeObject(ObjectOutputStream s) throws IOException { |
2085 |
< |
synchronized(mutex) {s.defaultWriteObject();} |
2085 |
> |
synchronized (mutex) {s.defaultWriteObject();} |
2086 |
|
} |
2087 |
|
} |
2088 |
|
|
2101 |
|
* ... |
2102 |
|
* Set s = m.keySet(); // Needn't be in synchronized block |
2103 |
|
* ... |
2104 |
< |
* synchronized(m) { // Synchronizing on m, not s! |
2104 |
> |
* synchronized (m) { // Synchronizing on m, not s! |
2105 |
|
* Iterator i = s.iterator(); // Must be in synchronized block |
2106 |
|
* while (i.hasNext()) |
2107 |
|
* foo(i.next()); |
2114 |
|
* ... |
2115 |
|
* Set s2 = m2.keySet(); // Needn't be in synchronized block |
2116 |
|
* ... |
2117 |
< |
* synchronized(m) { // Synchronizing on m, not m2 or s2! |
2117 |
> |
* synchronized (m) { // Synchronizing on m, not m2 or s2! |
2118 |
|
* Iterator i = s.iterator(); // Must be in synchronized block |
2119 |
|
* while (i.hasNext()) |
2120 |
|
* foo(i.next()); |
2154 |
|
} |
2155 |
|
|
2156 |
|
public Comparator<? super K> comparator() { |
2157 |
< |
synchronized(mutex) {return sm.comparator();} |
2157 |
> |
synchronized (mutex) {return sm.comparator();} |
2158 |
|
} |
2159 |
|
|
2160 |
|
public SortedMap<K,V> subMap(K fromKey, K toKey) { |
2161 |
< |
synchronized(mutex) { |
2161 |
> |
synchronized (mutex) { |
2162 |
|
return new SynchronizedSortedMap<K,V>( |
2163 |
|
sm.subMap(fromKey, toKey), mutex); |
2164 |
|
} |
2165 |
|
} |
2166 |
|
public SortedMap<K,V> headMap(K toKey) { |
2167 |
< |
synchronized(mutex) { |
2167 |
> |
synchronized (mutex) { |
2168 |
|
return new SynchronizedSortedMap<K,V>(sm.headMap(toKey), mutex); |
2169 |
|
} |
2170 |
|
} |
2171 |
|
public SortedMap<K,V> tailMap(K fromKey) { |
2172 |
< |
synchronized(mutex) { |
2172 |
> |
synchronized (mutex) { |
2173 |
|
return new SynchronizedSortedMap<K,V>(sm.tailMap(fromKey),mutex); |
2174 |
|
} |
2175 |
|
} |
2176 |
|
|
2177 |
|
public K firstKey() { |
2178 |
< |
synchronized(mutex) {return sm.firstKey();} |
2178 |
> |
synchronized (mutex) {return sm.firstKey();} |
2179 |
|
} |
2180 |
|
public K lastKey() { |
2181 |
< |
synchronized(mutex) {return sm.lastKey();} |
2181 |
> |
synchronized (mutex) {return sm.lastKey();} |
2182 |
|
} |
2183 |
|
} |
2184 |
|
|