Class ExtendedLL

java.lang.Object
  extended byintroExam.LinkedList.LL
      extended byExtendedLL

public class ExtendedLL
extends LL

These methods are the candidates for the linked list question


Nested Class Summary
 
Nested classes inherited from class introExam.LinkedList.LL
LL.LLNode
 
Field Summary
 
Fields inherited from class introExam.LinkedList.LL
head
 
Constructor Summary
ExtendedLL()
           
 
Method Summary
 ExtendedLL getItemsNotPresent(ExtendedLL otherList)
          Creates and returns a new list, which contains exactly those items that are not present in this list, but that are present in the otherList.
 ExtendedLL intersection(ExtendedLL otherList)
          Creates and returns a new list, which contains exactly those items that are present in both lists
 boolean isSubset(ExtendedLL otherList)
          This method returns true if and only if the otherList is a subset of this list and false otherwise.
 void removeAllGreaterItems(java.lang.Comparable keyItem)
          Removes each and every item greater than the keyItem from the list.
 void removeAllMatchingItems(java.lang.Comparable keyItem)
          Removes each and every item equal to the keyItem from the list.
 void removeEvenItems()
          This removes items with even indexes from the list.
 void removeOddItems()
          Removes items with odd indexes from the list.
 ExtendedLL reverse()
          Creates and returns a new linked list referencing the same items as the original list, except organizing them in the opposite order.
 ExtendedLL xOr(ExtendedLL otherList)
          Creates and returns a new list, which contains exactly those items that are present in exactly one of the two lists, but not both.
 
Methods inherited from class introExam.LinkedList.LL
addFirst, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExtendedLL

public ExtendedLL()
Method Detail

removeAllMatchingItems

public void removeAllMatchingItems(java.lang.Comparable keyItem)
Removes each and every item equal to the keyItem from the list. The list is not changed in any other way.

In the event of an error, it does not change the list, instead it returns leaving the list in its prior condition.

Parameters:
keyItem - Each and every item within the list equal to this item is removed from the list.

removeAllGreaterItems

public void removeAllGreaterItems(java.lang.Comparable keyItem)
Removes each and every item greater than the keyItem from the list. The list is not changed in any other way.

In the event of an error, it does not change the list, instead it returns leaving the list in its prior condition.

Parameters:
keyItem - Each and every item within the list greater than this item is removed from the list.

removeOddItems

public void removeOddItems()
Removes items with odd indexes from the list. The first item in the list has index 0, the second index 1, &c. The 0th index is not to considered an odd index.

In the event of an error, it does not change the list, instead it returns leaving the list in its prior condition.


removeEvenItems

public void removeEvenItems()
This removes items with even indexes from the list. The first item in the list is at index 0, the second is at index 1, &c. The 0th index is considered an even index for the purpose of this method.

In the event of an error, it does not change the list, instead it returns leaving the list in its prior condition.


getItemsNotPresent

public ExtendedLL getItemsNotPresent(ExtendedLL otherList)
Creates and returns a new list, which contains exactly those items that are not present in this list, but that are present in the otherList.

This method does not change either of the original lists.

In the event of an error, it returns an empty list.

Parameters:
otherList - is the list to be compared with this list

Returns:
A list containing all items that are not present in this list but that are present in the otherList.

intersection

public ExtendedLL intersection(ExtendedLL otherList)
Creates and returns a new list, which contains exactly those items that are present in both lists

Each original list may have duplicate items, but the resulting list should have no more than one instance of each item

This method does not change either of the original lists

In the event of an error, it returns an empty list.

Parameters:
otherList - is the list to be compared with this list

Returns:
A new list, which contains exactly those items that are present in both lists

xOr

public ExtendedLL xOr(ExtendedLL otherList)
Creates and returns a new list, which contains exactly those items that are present in exactly one of the two lists, but not both.

Each original list may have duplicate items, but the resulting list should have no more than one instance of each item

It does not change either of the original lists

In the event of an error, it returns an empty list.

Parameters:
otherList - is the list that should be compared with this list

Returns:
a new list, which contains exactly those items that are present in exactly one of the two lists, but not both.

isSubset

public boolean isSubset(ExtendedLL otherList)
This method returns true if and only if the otherList is a subset of this list and false otherwise. One list is a subset of the other list if it has exactly the same items, or some of the items, but no extra items.

The equality of items is evaluated by equals() or compareTo() on the item contained within the list.

This method is not sensitive to duplicate instances of an item in either list. For example, {a, a, b} is a subset of {a, b} and {a, b} is a subset of {a, a, b}

This method does not change either of the two lists.

In the event of an error, it returns false.

Parameters:
otherList - is the list to be compared to this list

Returns:
true if the otherList is a subset of the target list, false otherwise

reverse

public ExtendedLL reverse()
Creates and returns a new linked list referencing the same items as the original list, except organizing them in the opposite order. For example, the last item in the original list is the first item in the resulting list and vice versa.

In the event of an error, it returns null.

Returns:
A linked list referencing exactly the same items as the original, except in the reverse order. Empty if originally empty.