Browse Source

上传文件至 'w8'

main
peisishuang 2 months ago
parent
commit
6599540f9f
  1. BIN
      w8/AI协同文件.docx
  2. BIN
      w8/Cache.class
  3. BIN
      w8/Pair.class
  4. 65
      w8/Pair.java

BIN
w8/AI协同文件.docx

Binary file not shown.

BIN
w8/Cache.class

Binary file not shown.

BIN
w8/Pair.class

Binary file not shown.

65
w8/Pair.java

@ -0,0 +1,65 @@
import java.util.HashMap;
import java.util.Map;
public class Pair<K, V> {
private K first;
private V second;
public Pair(K first, V second) {
this.first = first;
this.second = second;
}
public K getFirst() {
return first;
}
public V getSecond() {
return second;
}
public Pair<V, K> swap() {
return new Pair<>(second, first);
}
@Override
public String toString() {
return "Pair{" + first + ", " + second + "}";
}
}
class Cache<K, V> {
private final Map<K, V> cache;
public Cache() {
this.cache = new HashMap<>();
}
public void put(K key, V value) {
cache.put(key, value);
}
public V get(K key) {
return cache.get(key);
}
public V remove(K key) {
return cache.remove(key);
}
public void clear() {
cache.clear();
}
public boolean containsKey(K key) {
return cache.containsKey(key);
}
public int size() {
return cache.size();
}
public boolean isEmpty() {
return cache.isEmpty();
}
}
Loading…
Cancel
Save