From 444ffc56066cd92217faaad00b3a4dec3fc43bd5 Mon Sep 17 00:00:00 2001 From: zhouzihao Date: Wed, 29 Apr 2026 15:27:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20'W8=E5=91=A8=E6=A2=93=E6=B5=A9202506050319'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- W8周梓浩202506050319/Pair.java | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 W8周梓浩202506050319/Pair.java diff --git a/W8周梓浩202506050319/Pair.java b/W8周梓浩202506050319/Pair.java new file mode 100644 index 0000000..8c92219 --- /dev/null +++ b/W8周梓浩202506050319/Pair.java @@ -0,0 +1,45 @@ +import java.util.HashMap; +import java.util.Map; + +public class Pair{ + private K key; + private V value; + + public Pair(K key,V value){ + this.key=key; + this.value=value; + } + public K getKey(){ + return key; + } + public V getValue(){ + return value; + } + + public Pair swap(){ + return new Pair<>(this.value,this.key); + } + + + public class Cache{ + private Map storage; + public Cache(){ + this.storage=new HashMap<>();//字典类型 + } + public void put(K key,V value){ + storage.put(key,value); + } + public V get(K key){ + return storage.get(key); + } + public V remove(K key){ + return storage.remove(key); + } + public int size(){ + return storage.size(); + } + public boolean isEMpty(){ + return storage.isEmpty(); + } + } +}