SlideShare a Scribd company logo
Note: Can someone help me with the private E get(int index, int currentIndex, Node n)method.
The code is not running. Also I need help with the public void add(int index, E element) method
too. Please use the parameters provided with the code to solve. package edu.ust.cisc; import
java.util.Iterator; import java.util.NoSuchElementException; public class CiscSortedLinkedList
> implements CiscList { /** * A reference to this list's dummy node. Its next reference should
refer to the node containing the first element * in this list, or it should refer to itself if the list is
empty. The next reference within the node containing * the last element in this list should refer to
dummy, thus creating a cyclic list. */ private Node dummy; /** * Number of elements in the list.
*/ private int size; /** * Constructs an empty CiscSortedLinkedList instance with a non-null
dummy node whose next reference refers to * itself. */ public CiscSortedLinkedList() { dummy
= new Node<>(null, null); dummy.next = dummy; } /** * Returns the number of elements in
this list. * * @return the number of elements in this list */ @Override public int size() { return
size; } /** * Returns {@code true} if this list contains no elements. * * @return {@code true} if
this list contains no elements */ @Override public boolean isEmpty() { return size==0; } /** *
Returns {@code true} if this list contains the specified element (compared using the {@code
equals} method). * This implementation should stop searching as soon as it is able to determine
that the specified element is not * present. * * @param o element whose presence in this list is to
be tested * @return {@code true} if this list contains the specified element * @throws
NullPointerException if the specified element is null */ @Override public boolean
contains(Object o) { if(o==null){ throw new NullPointerException(); } return
containsHelper(o,dummy.next); } private boolean containsHelper(Object o, Node node){
if(node== dummy){ return false; } else if(o.equals(node.data)){ return true; } else{ return
containsHelper(o,node.next); } } /** * Returns an iterator over the elements in this list in proper
sequence. * * @return an iterator over the elements in this list in proper sequence */ @Override
public Iterator iterator() { //return new Iterator (){ //private Node curr = dummy.next; //private
Node prev = dummy; //private boolean canRemove = false; return null; } /** * Returns an array
containing all of the elements in this list in proper sequence (from first to last element). *
The returned array will be "safe" in that no references to it are maintained by this list. (In other
words, * this method must allocate a new array even if this list is backed by an array). The caller
is thus free to modify * the returned array. * * @return an array containing all of the elements in
this list in proper sequence */ @Override public Object[] toArray() { Object[] arr = new
Object[size]; int i = 0; for(Node current = dummy;current!=null;current= current.next){ arr[i++]
= current.data; } return arr; } /** * {@link #toArray} recursive helper method. Adds the element
contained in the specified node to the specified index * in the specified array. Recursion stops
when the specified node is the dummy node. * * @param arr the array into which each element
in this list should be added * @param index the index into which the next element in this list
should be added * @param n the node containing the next element in this list to add to the array
*/ private void toArray(Object[] arr, int index, Node n) { } /** * Adds the specified element to
its sorted location in this list. * *
Lists may place the specified element at arbitrary locations if desired. In particular, an ordered
list will * insert the specified element at its sorted location. List classes should clearly specify in
their documentation * how elements will be added to the list if different from the default
behavior (end of this list). * * @param value element to be added to this list * @return {@code
true} * @throws NullPointerException if the specified element is null */ @Override public
boolean add(E value) { return false; } /** * {@link #add} recursive helper method. Adds the
specified value to the list in a new node following the specified * node (if that is the appropriate
location in the list). * * @param value element to be added to this list * @param n a reference to
the node possibly prior to the one created by this method */ private void add(E value, Node n) {
} /** * Removes the first occurrence of the specified element from this list, if it is present. If this
list does not * contain the element, it is unchanged. Returns {@code true} if this list contained
the specified element. This * implementation should stop searching as soon as it is able to
determine that the specified element is not * present. * * @param o element to be removed from
this list, if present * @return {@code true} if this list contained the specified element * @throws
NullPointerException if the specified element is null */ @Override public boolean
remove(Object o) { if(o==null){ throw new NullPointerException(); } Node curr = dummy.next;
Node prev = dummy; while (curr != dummy && !o.equals(curr.data)) { prev = curr; curr =
curr.next; } if (curr == dummy) { return false; } else { System.out.println("Removing
Data:"+curr.data); prev.next = curr.next; size--; return true; } } /** * {@link #remove} recursive
helper method. Removes the node following n if it contains the specified element. This *
implementation should stop searching as soon as it is able to determine that the specified element
is not * present. * * @param o element to be removed from this list, if present * @param n a
reference to the node prior to the one possibly containing the value to remove * @return */
private boolean remove(Object o, Node n) { return false; } /** * Removes all of the elements
from this list. The list will be empty after this call returns. @Override public void clear() {
dummy.next=dummy; size=0; } /** * Returns the element at the specified position in this list. *
* @param index index of the element to return * @return the element at the specified position in
this list * @throws IndexOutOfBoundsException if the index is out of range */ @Override
public E get(int index) { if(index<0 || index>=size){ throw new IndexOutOfBoundsException();
} Node curr = dummy.next; for(int i=0;i n) { if(index<0 || index>=size){ throw new
IndexOutOfBoundsException(); } Node curr = head; for(int i=0;i next_curr=curr.next;
curr.next=n; while(n.next) { n = n.next; //finding end of n headed linked list n.next =
next_curr;//adding rest linked list at end of n headed linked list } if(index==0) { return n; } else {
return head; } } /** * * @param index index of the element to replace * @param element
element to be stored at the specified position * @return the element previously at the specified
position * @throws UnsupportedOperationException if the {@code set} operation is not
supported by this list */ @Override public E set(int index, E element) { throw new
UnsupportedOperationException(); } /** * This operation is not supported by
CiscSortedLinkedList. * * @param index index at which the specified element is to be inserted *
@param element element to be inserted * @throws UnsupportedOperationException if the
{@code set} operation is not supported by this list */ @Override public void add(int index, E
element) { } /** * Appends all elements in the specified list to the end of this list, in the order
that they are returned by the * specified list's iterator. * * @param c list containing elements to
be added to this list * @return {@code true} if this list changed as a result of the call * @throws
NullPointerException if the specified list is null */ @Override public boolean addAll(CiscList
extends E> c) { return false; } /** * Removes the element at the specified position in this list.
Shifts any subsequent elements to the left * (subtracts one from their indices). Returns the
element that was removed from the list. * * @param index the index of the element to be
removed * @return the element previously at the specified position * @throws
IndexOutOfBoundsException if the index is out of range */ @Override public E remove(int
index) { return null; } /** * {@link #remove} recursive helper method. Removes the node
following n if it contains the element at the specified * index. * * @param index the index of the
element to be removed * @param currentIndex the index of the node parameter * @param n the
node containing the element at currentIndex * @return */ private E remove(int index, int
currentIndex, Node n) { return null; } /** * Returns the index of the first occurrence of the
specified element in this list, or -1 if this list does not * contain the element (compared using the
{@code equals} method). This implementation should stop searching as * soon as it is able to
determine that the specified element is not present. * @param o element to search for * @return
the index of the first occurrence of the specified element in this list, or -1 if this list does not *
contain the element * @throws NullPointerException if the specified element is null */
@Override public int indexOf(Object o) { if(o==null){ throw new NullPointerException(); }
return indexOf(o,0, dummy.next); } /** * {@link #indexOf} recursive helper method. Returns
currentIndex if the element contained in the node parameter is * equal to the specified element to
search for. This implementation should stop searching as soon as it is able to * determine that the
specified element is not present. * * @param o element to search for * @param currentIndex the
index of the node parameter * @param n the node containing the element at currentIndex *
@return the index of the first occurrence of the specified element in this list, or -1 if this list does
not * contain the element */ private int indexOf(Object o, int currentIndex, Node n) {
if(n.data.equals(o)){ return currentIndex; } else if(n==dummy){ return -1; } else
if(n.data.compareTo((E)o)>0){ return -1; } else{ return indexOf(o,currentIndex+1,n.next); } }
/** * Returns a string representation of this list. This string should consist of a comma separated
list of values * contained in this list, in order, surrounded by square brackets (examples: [3, 6, 7]
and []). * * @return a string representation of this list */ public String toString() { return null; }
/** * {@link #toString} recursive helper method. Returns a string representation of this list,
beginning with the * element in the specified node * * @param n the node containing the next
element to append to the string * @return a string representation of this list, beginning with the
element in the specified node */ private String toString(Node n) { return null; } private static
class Node { private E data; private Node next; private Node(E data, Node next) { this.data =
data; this.next = next; } } private class CiscLinkedListIterator implements Iterator { /** * A
reference to the node containing the next element to return, or to the dummy node if there are no
more * elements to return. */ private Node nextNode; /** * Constructs an iterator ready to return
the first element in the list (if present). */ public CiscLinkedListIterator() { } /** * Returns
{@code true} if the iteration has more elements. (In other words, returns {@code true} if *
{@link #next} would return an element rather than throwing an exception.) * * @return {@code
true} if the iteration has more elements */ @Override public boolean hasNext() { return false; }
/** * Returns the next element in the iteration. * * @return the next element in the iteration *
@throws NoSuchElementException if the iteration has no more elements */ @Override public E
next() { return null; } } }
Note- Can someone help me with the private E get(int index- int curren (1).docx

More Related Content

PDF
Note- Can someone help me with the Public boolean add(E value) method.pdf
DOCX
Please complete all the code as per instructions in Java programming.docx
PDF
import java.util.Iterator; import java.util.NoSuchElementException; .pdf
PDF
STAGE 2 The Methods 65 points Implement all the methods t.pdf
PDF
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
PDF
Given below is the completed implementation of MyLinkedList class. O.pdf
PDF
import java-util--- public class MyLinkedList{ public static void.pdf
PDF
Fix my codeCode.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdf
Please complete all the code as per instructions in Java programming.docx
import java.util.Iterator; import java.util.NoSuchElementException; .pdf
STAGE 2 The Methods 65 points Implement all the methods t.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
Given below is the completed implementation of MyLinkedList class. O.pdf
import java-util--- public class MyLinkedList{ public static void.pdf
Fix my codeCode.pdf

Similar to Note- Can someone help me with the private E get(int index- int curren (1).docx (20)

PDF
Help please!!(Include your modified DList.java source code file in.pdf
PDF
Hi,I have added the methods and main class as per your requirement.pdf
PDF
public class MyLinkedListltE extends ComparableltEgtg.pdf
PDF
Please help me to make a programming project I have to sue them today- (1).pdf
PDF
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
DOCX
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
PDF
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdf
PDF
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PDF
To complete the task, you need to fill in the missing code. I’ve inc.pdf
PDF
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
PDF
This is problem is same problem which i submitted on 22017, I just.pdf
PDF
Rewrite this code so it can use a generic type instead of integers. .pdf
PDF
The LinkedList1 class implements a Linked list. class.pdf
PDF
There are a couple of new methods that you will be writing for this pr.pdf
PDF
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
PDF
Submit1) Java Files2) Doc file with the following contents.pdf
PDF
-JAVA-provide a test class that do the required -you may add met.pdf
DOCX
public class ThreeTenDLList-T- implements Iterable-T- { -- doubly.docx
PDF
import java-util-Iterator- import java-util-NoSuchElementException- im.pdf
PDF
please read below it will tell you what we are using L.pdf
Help please!!(Include your modified DList.java source code file in.pdf
Hi,I have added the methods and main class as per your requirement.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdf
Please help me to make a programming project I have to sue them today- (1).pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
This is problem is same problem which i submitted on 22017, I just.pdf
Rewrite this code so it can use a generic type instead of integers. .pdf
The LinkedList1 class implements a Linked list. class.pdf
There are a couple of new methods that you will be writing for this pr.pdf
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
Submit1) Java Files2) Doc file with the following contents.pdf
-JAVA-provide a test class that do the required -you may add met.pdf
public class ThreeTenDLList-T- implements Iterable-T- { -- doubly.docx
import java-util-Iterator- import java-util-NoSuchElementException- im.pdf
please read below it will tell you what we are using L.pdf

More from VictorzH8Bondx (20)

DOCX
A large bullfrog hops onto a prime spot on log and shoves off a turtle.docx
DOCX
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docx
DOCX
Pattern recognition is one of the core tasks in data mining- Direction.docx
DOCX
Pathogenesis of yersinia bacteria- And Virulence factors of yersinia.docx
DOCX
Pareto Efficiency- clearly provide the following- (1) establish the re.docx
DOCX
Part - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docx
DOCX
P90- lbps (Type an integer or a decimal- Do not round-).docx
DOCX
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docx
DOCX
P(X-17)-n-20-p-0-9.docx
DOCX
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docx
DOCX
Over the past few decades of warming- most biological organisms have a.docx
DOCX
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docx
DOCX
Out of Trait- behavioural- relational and contingency approaches of le.docx
DOCX
Output of electron transport chain (2-2).docx
DOCX
Overview Dagnostic coding and reporting guidelines for outpatient serv.docx
DOCX
out of Stanford University and founded the blood testing company clini.docx
DOCX
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docx
DOCX
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docx
DOCX
Oriole Marine Products began the year with 10 units of marine floats a.docx
DOCX
Organizations use corporate strategy to select target domains- O.docx
A large bullfrog hops onto a prime spot on log and shoves off a turtle.docx
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docx
Pattern recognition is one of the core tasks in data mining- Direction.docx
Pathogenesis of yersinia bacteria- And Virulence factors of yersinia.docx
Pareto Efficiency- clearly provide the following- (1) establish the re.docx
Part - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docx
P90- lbps (Type an integer or a decimal- Do not round-).docx
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docx
P(X-17)-n-20-p-0-9.docx
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docx
Over the past few decades of warming- most biological organisms have a.docx
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docx
Out of Trait- behavioural- relational and contingency approaches of le.docx
Output of electron transport chain (2-2).docx
Overview Dagnostic coding and reporting guidelines for outpatient serv.docx
out of Stanford University and founded the blood testing company clini.docx
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docx
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docx
Oriole Marine Products began the year with 10 units of marine floats a.docx
Organizations use corporate strategy to select target domains- O.docx

Recently uploaded (20)

PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Computing-Curriculum for Schools in Ghana
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Institutional Correction lecture only . . .
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
Classroom Observation Tools for Teachers
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Cell Types and Its function , kingdom of life
PDF
RMMM.pdf make it easy to upload and study
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
202450812 BayCHI UCSC-SV 20250812 v17.pptx
VCE English Exam - Section C Student Revision Booklet
Computing-Curriculum for Schools in Ghana
Chinmaya Tiranga quiz Grand Finale.pdf
A systematic review of self-coping strategies used by university students to ...
Institutional Correction lecture only . . .
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Final Presentation General Medicine 03-08-2024.pptx
Complications of Minimal Access Surgery at WLH
Classroom Observation Tools for Teachers
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Microbial disease of the cardiovascular and lymphatic systems
Supply Chain Operations Speaking Notes -ICLT Program
Cell Types and Its function , kingdom of life
RMMM.pdf make it easy to upload and study
O7-L3 Supply Chain Operations - ICLT Program
3rd Neelam Sanjeevareddy Memorial Lecture.pdf

Note- Can someone help me with the private E get(int index- int curren (1).docx

  • 1. Note: Can someone help me with the private E get(int index, int currentIndex, Node n)method. The code is not running. Also I need help with the public void add(int index, E element) method too. Please use the parameters provided with the code to solve. package edu.ust.cisc; import java.util.Iterator; import java.util.NoSuchElementException; public class CiscSortedLinkedList > implements CiscList { /** * A reference to this list's dummy node. Its next reference should refer to the node containing the first element * in this list, or it should refer to itself if the list is empty. The next reference within the node containing * the last element in this list should refer to dummy, thus creating a cyclic list. */ private Node dummy; /** * Number of elements in the list. */ private int size; /** * Constructs an empty CiscSortedLinkedList instance with a non-null dummy node whose next reference refers to * itself. */ public CiscSortedLinkedList() { dummy = new Node<>(null, null); dummy.next = dummy; } /** * Returns the number of elements in this list. * * @return the number of elements in this list */ @Override public int size() { return size; } /** * Returns {@code true} if this list contains no elements. * * @return {@code true} if this list contains no elements */ @Override public boolean isEmpty() { return size==0; } /** * Returns {@code true} if this list contains the specified element (compared using the {@code equals} method). * This implementation should stop searching as soon as it is able to determine that the specified element is not * present. * * @param o element whose presence in this list is to be tested * @return {@code true} if this list contains the specified element * @throws NullPointerException if the specified element is null */ @Override public boolean contains(Object o) { if(o==null){ throw new NullPointerException(); } return containsHelper(o,dummy.next); } private boolean containsHelper(Object o, Node node){ if(node== dummy){ return false; } else if(o.equals(node.data)){ return true; } else{ return containsHelper(o,node.next); } } /** * Returns an iterator over the elements in this list in proper sequence. * * @return an iterator over the elements in this list in proper sequence */ @Override public Iterator iterator() { //return new Iterator (){ //private Node curr = dummy.next; //private Node prev = dummy; //private boolean canRemove = false; return null; } /** * Returns an array containing all of the elements in this list in proper sequence (from first to last element). * The returned array will be "safe" in that no references to it are maintained by this list. (In other words, * this method must allocate a new array even if this list is backed by an array). The caller is thus free to modify * the returned array. * * @return an array containing all of the elements in this list in proper sequence */ @Override public Object[] toArray() { Object[] arr = new Object[size]; int i = 0; for(Node current = dummy;current!=null;current= current.next){ arr[i++] = current.data; } return arr; } /** * {@link #toArray} recursive helper method. Adds the element contained in the specified node to the specified index * in the specified array. Recursion stops when the specified node is the dummy node. * * @param arr the array into which each element in this list should be added * @param index the index into which the next element in this list should be added * @param n the node containing the next element in this list to add to the array */ private void toArray(Object[] arr, int index, Node n) { } /** * Adds the specified element to its sorted location in this list. * * Lists may place the specified element at arbitrary locations if desired. In particular, an ordered list will * insert the specified element at its sorted location. List classes should clearly specify in their documentation * how elements will be added to the list if different from the default behavior (end of this list). * * @param value element to be added to this list * @return {@code true} * @throws NullPointerException if the specified element is null */ @Override public
  • 2. boolean add(E value) { return false; } /** * {@link #add} recursive helper method. Adds the specified value to the list in a new node following the specified * node (if that is the appropriate location in the list). * * @param value element to be added to this list * @param n a reference to the node possibly prior to the one created by this method */ private void add(E value, Node n) { } /** * Removes the first occurrence of the specified element from this list, if it is present. If this list does not * contain the element, it is unchanged. Returns {@code true} if this list contained the specified element. This * implementation should stop searching as soon as it is able to determine that the specified element is not * present. * * @param o element to be removed from this list, if present * @return {@code true} if this list contained the specified element * @throws NullPointerException if the specified element is null */ @Override public boolean remove(Object o) { if(o==null){ throw new NullPointerException(); } Node curr = dummy.next; Node prev = dummy; while (curr != dummy && !o.equals(curr.data)) { prev = curr; curr = curr.next; } if (curr == dummy) { return false; } else { System.out.println("Removing Data:"+curr.data); prev.next = curr.next; size--; return true; } } /** * {@link #remove} recursive helper method. Removes the node following n if it contains the specified element. This * implementation should stop searching as soon as it is able to determine that the specified element is not * present. * * @param o element to be removed from this list, if present * @param n a reference to the node prior to the one possibly containing the value to remove * @return */ private boolean remove(Object o, Node n) { return false; } /** * Removes all of the elements from this list. The list will be empty after this call returns. @Override public void clear() { dummy.next=dummy; size=0; } /** * Returns the element at the specified position in this list. * * @param index index of the element to return * @return the element at the specified position in this list * @throws IndexOutOfBoundsException if the index is out of range */ @Override public E get(int index) { if(index<0 || index>=size){ throw new IndexOutOfBoundsException(); } Node curr = dummy.next; for(int i=0;i n) { if(index<0 || index>=size){ throw new IndexOutOfBoundsException(); } Node curr = head; for(int i=0;i next_curr=curr.next; curr.next=n; while(n.next) { n = n.next; //finding end of n headed linked list n.next = next_curr;//adding rest linked list at end of n headed linked list } if(index==0) { return n; } else { return head; } } /** * * @param index index of the element to replace * @param element element to be stored at the specified position * @return the element previously at the specified position * @throws UnsupportedOperationException if the {@code set} operation is not supported by this list */ @Override public E set(int index, E element) { throw new UnsupportedOperationException(); } /** * This operation is not supported by CiscSortedLinkedList. * * @param index index at which the specified element is to be inserted * @param element element to be inserted * @throws UnsupportedOperationException if the {@code set} operation is not supported by this list */ @Override public void add(int index, E element) { } /** * Appends all elements in the specified list to the end of this list, in the order that they are returned by the * specified list's iterator. * * @param c list containing elements to be added to this list * @return {@code true} if this list changed as a result of the call * @throws NullPointerException if the specified list is null */ @Override public boolean addAll(CiscList extends E> c) { return false; } /** * Removes the element at the specified position in this list. Shifts any subsequent elements to the left * (subtracts one from their indices). Returns the element that was removed from the list. * * @param index the index of the element to be removed * @return the element previously at the specified position * @throws IndexOutOfBoundsException if the index is out of range */ @Override public E remove(int index) { return null; } /** * {@link #remove} recursive helper method. Removes the node
  • 3. following n if it contains the element at the specified * index. * * @param index the index of the element to be removed * @param currentIndex the index of the node parameter * @param n the node containing the element at currentIndex * @return */ private E remove(int index, int currentIndex, Node n) { return null; } /** * Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not * contain the element (compared using the {@code equals} method). This implementation should stop searching as * soon as it is able to determine that the specified element is not present. * @param o element to search for * @return the index of the first occurrence of the specified element in this list, or -1 if this list does not * contain the element * @throws NullPointerException if the specified element is null */ @Override public int indexOf(Object o) { if(o==null){ throw new NullPointerException(); } return indexOf(o,0, dummy.next); } /** * {@link #indexOf} recursive helper method. Returns currentIndex if the element contained in the node parameter is * equal to the specified element to search for. This implementation should stop searching as soon as it is able to * determine that the specified element is not present. * * @param o element to search for * @param currentIndex the index of the node parameter * @param n the node containing the element at currentIndex * @return the index of the first occurrence of the specified element in this list, or -1 if this list does not * contain the element */ private int indexOf(Object o, int currentIndex, Node n) { if(n.data.equals(o)){ return currentIndex; } else if(n==dummy){ return -1; } else if(n.data.compareTo((E)o)>0){ return -1; } else{ return indexOf(o,currentIndex+1,n.next); } } /** * Returns a string representation of this list. This string should consist of a comma separated list of values * contained in this list, in order, surrounded by square brackets (examples: [3, 6, 7] and []). * * @return a string representation of this list */ public String toString() { return null; } /** * {@link #toString} recursive helper method. Returns a string representation of this list, beginning with the * element in the specified node * * @param n the node containing the next element to append to the string * @return a string representation of this list, beginning with the element in the specified node */ private String toString(Node n) { return null; } private static class Node { private E data; private Node next; private Node(E data, Node next) { this.data = data; this.next = next; } } private class CiscLinkedListIterator implements Iterator { /** * A reference to the node containing the next element to return, or to the dummy node if there are no more * elements to return. */ private Node nextNode; /** * Constructs an iterator ready to return the first element in the list (if present). */ public CiscLinkedListIterator() { } /** * Returns {@code true} if the iteration has more elements. (In other words, returns {@code true} if * {@link #next} would return an element rather than throwing an exception.) * * @return {@code true} if the iteration has more elements */ @Override public boolean hasNext() { return false; } /** * Returns the next element in the iteration. * * @return the next element in the iteration * @throws NoSuchElementException if the iteration has no more elements */ @Override public E next() { return null; } } }