Da
t
a Struc
tur
es Spring
2011
The Fin
al
Pr
oject
Xi
ao
Ji
a
April
2
nd
, 2011
The Fin
al
Pr
oject
•
BE
E
S:
B
eginner
s’
E
duc
ati
onal
E
mula
tion of
S
TL
•
Deadline:
J
une 20
th
, 2011 (18
th
w
ee
k)
•
Gr
ading
–
Basic
func
tionalitie
s
(80%)
–
Pe
rform
anc
e
,
r
eports, et
c. (20%)
•
Con
tribut
or
s
–
Tian
xing
He
–
Jiejun
Zhang
Con
t
ainer
s
In
t
er
f
ace
Hash
T
able
R
esi
z
abl
e
Arr
a
y
Bal
anc
ed
T
r
ee
Link
ed Li
s
t
Implementation
Set
HashSet
T
r
eeSe
t
Lis
t
Arra
yLi
s
t
Li
nk
edLis
t
Map
HashMap
T
r
eeM
ap
Ther
e
ar
e it
er
a
t
or
s
f
or
these c
on
t
ainer
s.
Arr
a
yLis
t
•
ensureCapac
ity(int
mi
nCapacity)
•
clear()
•
size()
•
isEmpty()
•
add(const E
&e)
•
add(int ind
ex, cons
t
E &element)
•
contains(co
nst E &e
)
•
get(int ind
ex)
•
set(int ind
ex, cons
t
E &element)
Arr
a
yLis
t
(con
t
’)
•
inde
xOf(co
nst
E &
e)
•
last
Inde
xOf(cons
t
E &
e)
•
remo
veIn
dex(int
i
ndex
)
•
remo
ve(c
onst
E &
e
)
•
remo
veRa
nge(int
fro
m, i
nt t
o)
•
subL
ist(in
t fr
om,
int
to)
Arr
a
yLis
t::Iter
a
t
or
•
bool
h
asNe
xt
()
•
E& n
ext(
)
–
r
etrieve th
e curren
t
element
–
a
dvance the
iterato
r
itself
•
void
rem
ove(
)
–
throws
Elem
entNotEx
is
t
•
(sor
ted)
Arr
a
yLis
t::
Cons
tIter
a
t
or
•
bool
h
asNe
xt
()
•
cons
t E&
nex
t()
•
(sor
ted)
Link
edLis
t
•
add(
int
inde
x, c
o
nst
T &
e
lem)
•
add(
cons
t T
&
ele
m)
•
addF
irst(c
onst
T
&
e
lem)
•
clea
r()
•
cont
ains
(con
st T
&
e
lem)
•
get(
int
inde
x)
•
getF
irst
()
•
getL
ast
()
Link
edLis
t (con
t
’)
•
indexOf
(con
st T &el
em
)
•
isEmpty()
•
removeIndex
(int ind
ex
)
•
remove(cons
t T &
ele
m)
•
removeFirst
()
•
removeLast
()
•
set(int ind
ex, cons
t
T &elem
)
•
size()
•
subList
(int
from, i
nt
to)
Link
edLis
t
’
s
Iter
a
t
or
s
•
Sort
ed
•
All
el
eme
n
ts
should be it
er
at
ed.
HashSe
t / HashMap
clas
s Hash
int
{
publ
ic:
stat
ic i
nt hashc
o
de(int
obj)
{
retu
rn obj;
// h
ash
it h
ere
}
};
Hash
Set<
int,
H
ash
int> h
ash;
HashSe
t
’
s
Iter
a
t
or
s
•
Unsort
ed
•
All
el
eme
n
ts
should be it
er
at
ed.
T
r
eeSet / T
r
eeMap
•
Impl
eme
n
t
ed us
ing a
balan
ced
tree
•
Comparison:
operator
<
•
The i
t
er
at
or mus
t it
er
at
e i
n
the or
der
det
ermi
ned
by
operator
<
(fr
om
the small
es
t t
o the l
ar
g
es
t)
Questions?
•
Find
out mor
e det
ails on our w
ebsit
e.
•
Mak
e
pr
ogr
ess
ev
ery
da
y
.