/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimeoutMap.java
ViewVC logotype

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimeoutMap.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 429 by torben, Fri Oct 9 08:53:03 2009 UTC revision 804 by torben, Mon Jun 7 12:13:10 2010 UTC
# Line 1  Line 1 
1  package dk.thoerup.traininfoservice.banedk;  package dk.thoerup.traininfoservice.banedk;
2    
3  import java.util.concurrent.ConcurrentHashMap;  import java.util.ArrayList;
4  import java.util.Collection;  import java.util.Collection;
5  import java.util.Map;  import java.util.Map;
6  import java.util.Set;  import java.util.Set;
7    import java.util.concurrent.ConcurrentHashMap;
8    
9    
10    
# Line 35  public class TimeoutMap<K,V> implements Line 36  public class TimeoutMap<K,V> implements
36          }          }
37    
38          @Override          @Override
39          public boolean containsKey(Object arg0) {          public boolean containsKey(Object key) {
40                  CacheItem<V> item = cache.get(arg0);                  return cache.containsKey(key);
                   
                 return (item != null);  
41          }          }
42    
43          @Override          @Override
44          public boolean containsValue(Object arg0) {          public boolean containsValue(Object arg0) {
45                  //TODO someday implement this                  return values().contains(arg0);        
                 throw new UnsupportedOperationException();  
                   
46          }          }
47    
48          @Override          @Override
# Line 66  public class TimeoutMap<K,V> implements Line 63  public class TimeoutMap<K,V> implements
63    
64          @Override          @Override
65          public void putAll(Map<? extends K, ? extends V> arg0) {          public void putAll(Map<? extends K, ? extends V> arg0) {
66                  //TODO someday implement this                  for(K key : arg0.keySet()) {
67                  throw new UnsupportedOperationException();                          this.put(key, arg0.get(key) );
68                    }
69          }          }
70    
71          @Override          @Override
# Line 82  public class TimeoutMap<K,V> implements Line 80  public class TimeoutMap<K,V> implements
80    
81          @Override          @Override
82          public Collection<V> values() {          public Collection<V> values() {
83                  //TODO someday implement this                  ArrayList<V> values = new ArrayList<V>();
84                  throw new UnsupportedOperationException();                  for (CacheItem<V> item : cache.values()) {
85                            values.add( item.value );
86                    }
87                    
88                    return values;
89    
90          }          }
91    
92          @Override          @Override
# Line 108  public class TimeoutMap<K,V> implements Line 111  public class TimeoutMap<K,V> implements
111          public V put(K key, V value) {                    public V put(K key, V value) {          
112                  CacheItem<V> item= new CacheItem<V>(value);                  CacheItem<V> item= new CacheItem<V>(value);
113                                    
114                  return cache.put(key, item).value;                  item = cache.put(key, item);
115                    
116                    if (item != null)
117                            return item.value;
118                    else
119                            return null;
120          }          }
121                    
122  }  }

Legend:
Removed from v.429  
changed lines
  Added in v.804

  ViewVC Help
Powered by ViewVC 1.1.20