Skip to content
Browse files

<ValueType>

  • Loading branch information...
1 parent 269e0b1 commit 53cd67cf7cdb0c268db5d1658a3943e6eb95decf @AirVan21 committed
Showing with 12 additions and 12 deletions.
  1. +9 −9 HW7.ex2/src/hw7/ex2/Set.java
  2. +3 −3 HW7.ex2/src/hw7/ex2/SetElement.java
View
18 HW7.ex2/src/hw7/ex2/Set.java
@@ -20,13 +20,13 @@ public Set() {
*/
public void addElement(ValueType value) {
if (amount == 0) {
- SetElement current = new SetElement(value);
+ SetElement<ValueType> current = new SetElement(value);
head = current;
tail = current;
amount++;
} else {
if (!exist(value)) {
- SetElement current = new SetElement(value);
+ SetElement<ValueType> current = new SetElement(value);
tail.connectNext(current);
tail = current;
amount++;
@@ -48,7 +48,7 @@ public boolean isEmpty() {
*/
public boolean exist(ValueType value) {
if (!this.isEmpty()) {
- SetElement help = head;
+ SetElement<ValueType> help = head;
while (help != tail.getNext()) {
if (help.getValue() == value) {
return true;
@@ -68,8 +68,8 @@ public boolean exist(ValueType value) {
*/
public void deleteElement(ValueType value) throws WrongActionException {
if (exist(value)) {
- SetElement previous = head;
- SetElement current = head.getNext();
+ SetElement<ValueType> previous = head;
+ SetElement<ValueType> current = head.getNext();
if (previous.getValue() == value) {
head = current;
} else {
@@ -93,7 +93,7 @@ public void deleteElement(ValueType value) throws WrongActionException {
*/
public Set<ValueType> union(Set<ValueType> set1, Set<ValueType> set2) {
Set<ValueType> unionSet = new Set();
- SetElement current = set1.head;
+ SetElement<ValueType> current = set1.head;
if (!set1.isEmpty()) {
while (current != set1.tail.getNext()) {
unionSet.addElement(current.getValue());
@@ -122,7 +122,7 @@ public void deleteElement(ValueType value) throws WrongActionException {
*/
public Set<ValueType> intersection(Set<ValueType> set1, Set<ValueType> set2) {
Set<ValueType> crossSet = new Set();
- SetElement current = set1.head;
+ SetElement<ValueType> current = set1.head;
if (!set1.isEmpty()) {
while (current != set1.tail.getNext()) {
if (set2.exist(current.getValue())) {
@@ -134,9 +134,9 @@ public void deleteElement(ValueType value) throws WrongActionException {
return crossSet;
}
- private SetElement head;
+ private SetElement<ValueType> head;
- private SetElement tail;
+ private SetElement<ValueType> tail;
private int amount;
}
View
6 HW7.ex2/src/hw7/ex2/SetElement.java
@@ -25,7 +25,7 @@ public ValueType getValue() {
/**
* Get SetElement which connected with this one
*/
- public SetElement getNext() {
+ public SetElement<ValueType> getNext() {
return this.next;
}
@@ -33,12 +33,12 @@ public SetElement getNext() {
* Connect current element with other one
* @param connected
*/
- public void connectNext(SetElement connected) {
+ public void connectNext(SetElement<ValueType> connected) {
this.next = connected;
}
private ValueType value;
- private SetElement next;
+ private SetElement<ValueType> next;
}

0 comments on commit 53cd67c

Please sign in to comment.
Something went wrong with that request. Please try again.