-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMapEntry.java
More file actions
74 lines (61 loc) · 1.63 KB
/
Copy pathMapEntry.java
File metadata and controls
74 lines (61 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package chapter17.nine;
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;
public class MapEntry<K, V> implements Map.Entry<K,V>{
private K key;
private V value;
public MapEntry(K next, V next2) {
// TODO Auto-generated constructor stub
key=next;
value=next2;
}
public K getKey() {
// TODO Auto-generated method stub
return key;
}
public V getValue() {
// TODO Auto-generated method stub
return value;
}
public V setValue(V v) {
// TODO Auto-generated method stub
V result=value;//È«¾Ö±äÁ¿»á±äÀ¶£¬¹þ¹þ
value=v;
return result;
}
public static <K extends Comparable<? super K>, V> Comparator<Entry<K, V>> comparingByKey() {
// TODO Auto-generated method stub
return null;
}
public static <K, V extends Comparable<? super V>> Comparator<Entry<K, V>> comparingByValue() {
// TODO Auto-generated method stub
return null;
}
public static <K, V> Comparator<Entry<K, V>> comparingByKey(
Comparator<? super K> cmp) {
// TODO Auto-generated method stub
return null;
}
public static <K, V> Comparator<Entry<K, V>> comparingByValue(
Comparator<? super V> cmp) {
// TODO Auto-generated method stub
return null;
}
@Override
public int hashCode() {
// TODO Auto-generated method stub
return (key==null? 0:key.hashCode())^(value==null?0:value.hashCode());
}
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
if(!(obj instanceof MapEntry)){
return false;
}
MapEntry me=(MapEntry) obj;
return (key==null?me.getKey()==null:key.equals(me.getKey())) &&
(value==null?
me.getValue()==null:value.equals(me.getValue()));
}
}