This repository was archived by the owner on Jan 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkedOccurrence.java
More file actions
58 lines (51 loc) · 1.35 KB
/
Copy pathLinkedOccurrence.java
File metadata and controls
58 lines (51 loc) · 1.35 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
import java.util.ArrayList;
public class LinkedOccurrence {
private Occurrence head;
public LinkedOccurrence() {
head = null;
}
//Inserts a new Link at the first of the list
public void insert(String name) {
Occurrence newOcc = new Occurrence(name);
newOcc.next = head;
head = newOcc;
}
public void printList() {
Occurrence temp = head;
while (head != null) {
head.printOcc();
head = head.next;
}
head = temp;
}
public int getSize() {
int counter = 0;
Occurrence temp = head;
while (head != null) {
counter++;
head = head.next;
}
head = temp;
return counter;
}
public ArrayList<Occurrence> toArray() {
ArrayList<Occurrence> array = new ArrayList<Occurrence>();
Occurrence temp = head;
while (head != null) {
array.add(head);
head = head.next;
}
head = temp;
return array;
}
public String toString() {
String arrayString = "";
Occurrence temp = head;
while (head != null) {
arrayString = head.getDocName() + " " + head.getTermFrequency() + "; " + arrayString;
head = head.next;
}
head = temp;
return arrayString;
}
}