ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ConcurrentHashMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ConcurrentHashMap.java (file contents):
Revision 1.11 by tim, Sat Jul 26 13:17:51 2003 UTC vs.
Revision 1.12 by tim, Thu Jul 31 16:43:47 2003 UTC

# Line 106 | Line 106 | public class ConcurrentHashMap<K, V> ext
106      private final Segment[] segments;
107  
108      private transient Set<K> keySet;
109 <    private transient Set/*<Map.Entry<K,V>>*/ entrySet;
109 >    private transient Set<Map.Entry<K,V>> entrySet;
110      private transient Collection<V> values;
111  
112      /* ---------------- Small Utilities -------------- */
# Line 130 | Line 130 | public class ConcurrentHashMap<K, V> ext
130       * Return the segment that should be used for key with given hash
131       */
132      private Segment<K,V> segmentFor(int hash) {
133 <        return segments[(hash >>> segmentShift) & segmentMask];
133 >        return (Segment<K,V>) segments[(hash >>> segmentShift) & segmentMask];
134      }
135  
136      /* ---------------- Inner Classes -------------- */
# Line 260 | Line 260 | public class ConcurrentHashMap<K, V> ext
260                  HashEntry[] tab = table;
261                  int len = tab.length;
262                  for (int i = 0 ; i < len; i++)
263 <                    for (HashEntry<K,V> e = tab[i] ; e != null ; e = e.next)
263 >                    for (HashEntry<K,V> e = (HashEntry<K,V>)tab[i] ; e != null ; e = e.next)
264                          if (value.equals(e.value))
265                              return true;
266              }
# Line 321 | Line 321 | public class ConcurrentHashMap<K, V> ext
321              for (int i = 0; i < oldCapacity ; i++) {
322                  // We need to guarantee that any existing reads of old Map can
323                  //  proceed. So we cannot yet null out each bin.
324 <                HashEntry<K,V> e = oldTable[i];
324 >                HashEntry<K,V> e = (HashEntry<K,V>)oldTable[i];
325  
326                  if (e != null) {
327                      HashEntry<K,V> next = e.next;
# Line 369 | Line 369 | public class ConcurrentHashMap<K, V> ext
369                  int c = count;
370                  HashEntry[] tab = table;
371                  int index = hash & (tab.length - 1);
372 <                HashEntry<K,V> first = tab[index];
372 >                HashEntry<K,V> first = (HashEntry<K,V>)tab[index];
373  
374                  HashEntry<K,V> e = first;
375                  for (;;) {
# Line 450 | Line 450 | public class ConcurrentHashMap<K, V> ext
450          public boolean equals(Object o) {
451              if (!(o instanceof Entry))
452                  return false;
453 <            Entry<K,V> e = (Entry)o;
453 >            Entry<K,V> e = (Entry<K,V>)o;
454              return (key.equals(e.getKey()) && value.equals(e.getValue()));
455          }
456  
# Line 695 | Line 695 | public class ConcurrentHashMap<K, V> ext
695       * @param t Mappings to be stored in this map.
696       */
697      public void putAll(Map<? extends K, ? extends V> t) {
698 <        Iterator it = t.entrySet().iterator();
698 >        Iterator<Map.Entry<? extends K, ? extends V>> it = t.entrySet().iterator();
699          while (it.hasNext()) {
700 <            Entry<K,V> e = (Entry<K, V>) it.next();
700 >            Entry<? extends K, ? extends V> e = it.next();
701              put(e.getKey(), e.getValue());
702          }
703      }
# Line 759 | Line 759 | public class ConcurrentHashMap<K, V> ext
759          int segs = segments.length;
760          int cap = (int)(size() / lf);
761          if (cap < segs) cap = segs;
762 <        ConcurrentHashMap t = new ConcurrentHashMap(cap, lf, segs);
762 >        ConcurrentHashMap<K,V> t = new ConcurrentHashMap<K,V>(cap, lf, segs);
763          t.putAll(this);
764          return t;
765      }
# Line 866 | Line 866 | public class ConcurrentHashMap<K, V> ext
866                  return;
867  
868              while (nextTableIndex >= 0) {
869 <                if ( (nextEntry = currentTable[nextTableIndex--]) != null)
869 >                if ( (nextEntry = (HashEntry<K,V>)currentTable[nextTableIndex--]) != null)
870                      return;
871              }
872  
873              while (nextSegmentIndex >= 0) {
874 <                Segment<K,V> seg = segments[nextSegmentIndex--];
874 >                Segment<K,V> seg = (Segment<K,V>)segments[nextSegmentIndex--];
875                  if (seg.count != 0) {
876                      currentTable = seg.table;
877                      for (int j = currentTable.length - 1; j >= 0; --j) {
878 <                        if ( (nextEntry = currentTable[j]) != null) {
878 >                        if ( (nextEntry = (HashEntry<K,V>)currentTable[j]) != null) {
879                              nextTableIndex = j - 1;
880                              return;
881                          }
# Line 949 | Line 949 | public class ConcurrentHashMap<K, V> ext
949          }
950      }
951  
952 <    private class EntrySet extends AbstractSet {
952 >    private class EntrySet extends AbstractSet<Map.Entry<K,V>> {
953          public Iterator<Map.Entry<K,V>> iterator() {
954              return new EntryIterator();
955          }
# Line 990 | Line 990 | public class ConcurrentHashMap<K, V> ext
990          s.defaultWriteObject();
991  
992          for (int k = 0; k < segments.length; ++k) {
993 <            Segment<K,V> seg = segments[k];
993 >            Segment<K,V> seg = (Segment<K,V>)segments[k];
994              seg.lock();
995              try {
996                  HashEntry[] tab = seg.table;
997                  for (int i = 0; i < tab.length; ++i) {
998 <                    for (HashEntry<K,V> e = tab[i]; e != null; e = e.next) {
998 >                    for (HashEntry<K,V> e = (HashEntry<K,V>)tab[i]; e != null; e = e.next) {
999                          s.writeObject(e.key);
1000                          s.writeObject(e.value);
1001                      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines