F1124004
5110309084
蒋舜宁
6/6:
array
deque
splay tree
separate chaining
Iterator
ConstIterator
addAll
addAll(*this,a)
Entry<K,V>
const key K
ElementNotExist()
{ throw ElementNotExist();}
seek(index)
store index or link?
head tail seek(index)
use head instead of NULL
splay – slower, and a waste!!!
ConstIterator’s problem
a secondary product of TreeSet
Entry<K,V>’s problem
separate chaining
a big prime
an array of LinkedList?
a secondary product of TreeSet
No LinkedList with both head and tail.
Add b elements. a of them are distinct.(a/b)
4
3.5
3
2.5
TreeSet
set
2
TreeSet_O2
set_O2
1.5
1
0.5
0
32768/1000000
237600/1000000
999800/1000000
1999600/2000000
Use ConstIterator to traverse a elements.
0.4
0.35
0.3
0.25
TreeSet
set
0.2
TreeSet_O2
set_O2
0.15
0.1
0.05
0
32768/1000000
237600/1000000
999800/1000000
1999600/2000000
Count 1,000,000 times (guarantee).
2.5
2
1.5
TreeSet
set
TreeSet_O2
1
set_O2
0.5
0
32768/1000000
237600/1000000
999800/1000000
1999600/2000000
Remove 1,000,000 elements in random order.
3
2.5
2
TreeSet
set
1.5
TreeSet_O2
set_O2
1
0.5
0
32768/1000000
237600/1000000
999800/1000000
1999600/2000000
Add b elements. a of them are distinct. (a/b)
2.5
2
1.5
HashMap
map
HashMap_O2
1
map_O2
0.5
0
32768/1000000
237600/1000000
999800/1000000
1999600/2000000
Use ConstIterator to traverse a elements.
0.2
0.18
0.16
0.14
0.12
HashMap
map
0.1
HashMap_O2
0.08
map_O2
0.06
0.04
0.02
0
32768/1000000
237600/1000000
999800/1000000
1999600/2000000
Count by Key 1,000,000 times (guarantee).
1
0.9
0.8
0.7
0.6
HashMap
map
0.5
HashMap_O2
0.4
map_O2
0.3
0.2
0.1
0
32768/1000000
237600/1000000
999800/1000000
1999600/2000000
Remove 1,000,000 elements in random order.
2
1.8
1.6
1.4
1.2
HashMap
map
1
HashMap_O2
0.8
map_O2
0.6
0.4
0.2
0
32768/1000000
237600/1000000
999800/1000000
1999600/2000000
ArrayList & vector?
LinkedList & list?
HashSet & set?
TreeMap & map?
Eliminate?
Platform?
Pursue test&ability or pursue speed?
Q&A
© Copyright 2025 Paperzz