FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaArithmetic/src/datastructure/map/Main.java at master · Edwardlinge/JavaArithmetic · GitHub
Edwardlinge
JavaArithmetic
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaArithmetic
/
src
/
datastructure
/
map
/
Main.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
48 lines (33 loc) · 1.43 KB
Breadcrumbs
JavaArithmetic
/
src
/
datastructure
/
map
/
Main.java
Copy path
File metadata and controls
48 lines (33 loc) · 1.43 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package
datastructure
.
map
;
import
java
.
util
.
ArrayList
;
public
class
Main
{
private
static
double
testMap
(
Map
<
String
,
Integer
>
map
,
String
filename
){
long
startTime
=
System
.
nanoTime
();
System
.
out
.
println
(
filename
);
ArrayList
<
String
>
words
=
new
ArrayList
<>();
if
(
FileOperation
.
readFile
(
filename
,
words
)) {
System
.
out
.
println
(
"Total words: "
+
words
.
size
());
for
(
String
word
:
words
){
if
(
map
.
contains
(
word
))
map
.
set
(
word
,
map
.
get
(
word
) +
1
);
else
map
.
add
(
word
,
1
);
}
System
.
out
.
println
(
"Total different words: "
+
map
.
getSize
());
System
.
out
.
println
(
"Frequency of PRIDE: "
+
map
.
get
(
"pride"
));
System
.
out
.
println
(
"Frequency of PREJUDICE: "
+
map
.
get
(
"prejudice"
));
}
long
endTime
=
System
.
nanoTime
();
return
(
endTime
-
startTime
) /
1000000000.0
;
}
public
static
void
main
(
String
[]
args
) {
String
filename
=
"pride-and-prejudice.txt"
;
BSTMap
<
String
,
Integer
>
bstMap
=
new
BSTMap
<>();
double
time1
=
testMap
(
bstMap
,
filename
);
System
.
out
.
println
(
"BST Map: "
+
time1
+
" s"
);
System
.
out
.
println
();
LinkedListMap
<
String
,
Integer
>
linkedListMap
=
new
LinkedListMap
<>();
double
time2
=
testMap
(
linkedListMap
,
filename
);
System
.
out
.
println
(
"Linked List Map: "
+
time2
+
" s"
);
}
}
Back
|
FazBrowse Home
|
New Git URL