jdk/src/share/classes/java/util/Collections.java
changeset 23746 ce60f7b62312
parent 22285 6c67737a5ac0
child 25171 5dd99a9e443b
equal deleted inserted replaced
23745:7898c52fcfb4 23746:ce60f7b62312
  1464         }
  1464         }
  1465         public void clear() {
  1465         public void clear() {
  1466             throw new UnsupportedOperationException();
  1466             throw new UnsupportedOperationException();
  1467         }
  1467         }
  1468 
  1468 
  1469         private transient Set<K> keySet = null;
  1469         private transient Set<K> keySet;
  1470         private transient Set<Map.Entry<K,V>> entrySet = null;
  1470         private transient Set<Map.Entry<K,V>> entrySet;
  1471         private transient Collection<V> values = null;
  1471         private transient Collection<V> values;
  1472 
  1472 
  1473         public Set<K> keySet() {
  1473         public Set<K> keySet() {
  1474             if (keySet==null)
  1474             if (keySet==null)
  1475                 keySet = unmodifiableSet(m.keySet());
  1475                 keySet = unmodifiableSet(m.keySet());
  1476             return keySet;
  1476             return keySet;
  2595         }
  2595         }
  2596         public void clear() {
  2596         public void clear() {
  2597             synchronized (mutex) {m.clear();}
  2597             synchronized (mutex) {m.clear();}
  2598         }
  2598         }
  2599 
  2599 
  2600         private transient Set<K> keySet = null;
  2600         private transient Set<K> keySet;
  2601         private transient Set<Map.Entry<K,V>> entrySet = null;
  2601         private transient Set<Map.Entry<K,V>> entrySet;
  2602         private transient Collection<V> values = null;
  2602         private transient Collection<V> values;
  2603 
  2603 
  2604         public Set<K> keySet() {
  2604         public Set<K> keySet() {
  2605             synchronized (mutex) {
  2605             synchronized (mutex) {
  2606                 if (keySet==null)
  2606                 if (keySet==null)
  2607                     keySet = new SynchronizedSet<>(m.keySet(), mutex);
  2607                     keySet = new SynchronizedSet<>(m.keySet(), mutex);
  3080         public boolean add(E e) {
  3080         public boolean add(E e) {
  3081             typeCheck(e);
  3081             typeCheck(e);
  3082             return c.add(e);
  3082             return c.add(e);
  3083         }
  3083         }
  3084 
  3084 
  3085         private E[] zeroLengthElementArray = null; // Lazily initialized
  3085         private E[] zeroLengthElementArray; // Lazily initialized
  3086 
  3086 
  3087         private E[] zeroLengthElementArray() {
  3087         private E[] zeroLengthElementArray() {
  3088             return zeroLengthElementArray != null ? zeroLengthElementArray :
  3088             return zeroLengthElementArray != null ? zeroLengthElementArray :
  3089                 (zeroLengthElementArray = zeroLengthArray(type));
  3089                 (zeroLengthElementArray = zeroLengthArray(type));
  3090         }
  3090         }
  3641             }
  3641             }
  3642             for (Map.Entry<K,V> e : checked)
  3642             for (Map.Entry<K,V> e : checked)
  3643                 m.put(e.getKey(), e.getValue());
  3643                 m.put(e.getKey(), e.getValue());
  3644         }
  3644         }
  3645 
  3645 
  3646         private transient Set<Map.Entry<K,V>> entrySet = null;
  3646         private transient Set<Map.Entry<K,V>> entrySet;
  3647 
  3647 
  3648         public Set<Map.Entry<K,V>> entrySet() {
  3648         public Set<Map.Entry<K,V>> entrySet() {
  3649             if (entrySet==null)
  3649             if (entrySet==null)
  3650                 entrySet = new CheckedEntrySet<>(m.entrySet(), valueType);
  3650                 entrySet = new CheckedEntrySet<>(m.entrySet(), valueType);
  3651             return entrySet;
  3651             return entrySet;
  4875         public boolean isEmpty()                                {return false;}
  4875         public boolean isEmpty()                                {return false;}
  4876         public boolean containsKey(Object key)             {return eq(key, k);}
  4876         public boolean containsKey(Object key)             {return eq(key, k);}
  4877         public boolean containsValue(Object value)       {return eq(value, v);}
  4877         public boolean containsValue(Object value)       {return eq(value, v);}
  4878         public V get(Object key)              {return (eq(key, k) ? v : null);}
  4878         public V get(Object key)              {return (eq(key, k) ? v : null);}
  4879 
  4879 
  4880         private transient Set<K> keySet = null;
  4880         private transient Set<K> keySet;
  4881         private transient Set<Map.Entry<K,V>> entrySet = null;
  4881         private transient Set<Map.Entry<K,V>> entrySet;
  4882         private transient Collection<V> values = null;
  4882         private transient Collection<V> values;
  4883 
  4883 
  4884         public Set<K> keySet() {
  4884         public Set<K> keySet() {
  4885             if (keySet==null)
  4885             if (keySet==null)
  4886                 keySet = singleton(k);
  4886                 keySet = singleton(k);
  4887             return keySet;
  4887             return keySet;