7 | * @param {
11 | protected P priority;
12 | protected V value;
13 |
14 | public PriorityQueueElement() {
15 | }
16 |
17 | public PriorityQueueElement(P priority, V value) {
18 | this.priority = priority;
19 | this.value = value;
20 | }
21 |
22 | public P getPriority() {
23 | return priority;
24 | }
25 |
26 | public void setPriority(P priority) {
27 | this.priority = priority;
28 | }
29 |
30 | public V getValue() {
31 | return value;
32 | }
33 |
34 | public void setValue(V value) {
35 | this.value = value;
36 | }
37 |
38 | @Override
39 | public String toString() {
40 | StringBuilder builder = new StringBuilder();
41 | builder.append(priority).append(":").append(value);
42 | return builder.toString();
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/datastructures/src/datastructures/lists/GenericList.java:
--------------------------------------------------------------------------------
1 | package datastructures.lists;
2 |
3 | /**
4 | * Generic List Interface
5 | *
6 | * @param > listOfLists = null;
16 |
17 | public CartesianProduct() {
18 | listOfLists = new ArrayList
>();
19 | }
20 |
21 | public void addList(String[] values) {
22 | List
> product() {
30 | List
> results = new ArrayList
>();
31 | product(listOfLists, new Stack
> lists, Stack
> results, int index) {
37 | if (index >= lists.size()) {
38 | results.add((List