SlideShare a Scribd company logo
1 of 7
Download to read offline
Help explain the code with line comments
public class CompletedList implements ListADT, Iterable
{
//Three instance variables
protected int count;
protected int modChange;
protected DoubleLinearNode head, tail;
//head and tail set to empty count set to zero
public CompletedList() {
head = tail = null;
count = 0;
}
//Override for head and tail, remove first number of list
@Override
public T removeFirst() throws NoSuchElementException
{
//if head is empty return error
if(isEmpty())
throw new NoSuchElementException("The collection is empty");
//Temp for each number set to head item
T temp = head.getItem();
//if first number equals last they are null
if(head == tail)
{
head = tail = null;
}
//else the ne
else if(head.getNext() == tail)
{
head.remove();
head = tail;
}
else
{
head = head.getNext();
head.getPrev().remove();
}
count--;
modChange++;
return temp;
}
@Override
public T removeLast() throws NoSuchElementException
{
if(isEmpty())
throw new NoSuchElementException("The collection is empty");
T temp = tail.getItem();
if(head == tail)
{
head = tail = null;
}
else if(head.getNext() == tail){
tail.remove();
tail = head;
}
else
{
tail = tail.getPrev();
tail.getNext().remove();
}
count--;
modChange++;
return temp;
}
@Override
public T remove( T element )
{
if(isEmpty())
throw new NoSuchElementException("The target is not in the collection");
if(tail.getItem().equals(element))
{
return removeLast();
}
for (DoubleLinearNode current = head; current != null; current = current.getNext())
{
if(current.getItem().equals(element))
{
if(current == head)
{
return removeFirst();
}
else
{
count--;
modChange++;
return current.remove();
}
}
}
throw new NoSuchElementException("The target is not in the collection");
}
@Override
public T first()
{
if (isEmpty())
throw new NoSuchElementException("The collection is empty");
return head.getItem();
}
@Override
public T last()
{
if (isEmpty())
throw new NoSuchElementException("The collection is empty");
return tail.getItem();
}
@Override
public boolean contains( T target )
{
if(isEmpty())
return false;
if(tail.getItem().equals(target))
{
return true;
}
for (DoubleLinearNode current = head; current != null; current = current.getNext())
{
if(current.getItem().equals(target))
{
return true;
}
}
return false;
}
@Override
public boolean isEmpty()
{
return count == 0;
}
@Override
public int size()
{
return count;
}
@Override
public Iterator iterator()
{
return new ListIterator(head);
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
for (DoubleLinearNode current = head; current != null; current = current.getNext())
{
sb.append(current.getItem()).append(' ');
}
return sb.toString();
}
private class ListIterator implements Iterator
{
private DoubleLinearNode current;
private int modNum;
public ListIterator( DoubleLinearNode node)
{
this.modNum = modChange;
this.current = node;
}
@Override
public boolean hasNext()
{
if(this.modNum != modChange)
throw new ConcurrentModificationException("The collection has been modified!");
if(this.current != null)
{
return this.current.getNext() != null;
}
else
{
return false;
}
}
@Override
public T next()
{
if (!this.hasNext())
throw new NoSuchElementException();
this.current = this.current.getNext();
return this.current.getItem();
}
@Override
public void remove()
{
if(current == head)
{
modNum++;
removeFirst();
current = head;
}
else if(current == tail)
{
modNum++;
removeLast();
current = tail;
} else
{
modNum++;
modChange++;
current = current.getNext();
current.getPrev().remove();
}
}
}
}

More Related Content

Similar to Help explain the code with line comments public class CompletedLis.pdf

Implement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdfImplement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdffootstatus
 
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfHelp please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfarorastores
 
Solve using java and using this Singly linked list classpublic cl.pdf
Solve using java and using this Singly linked list classpublic cl.pdfSolve using java and using this Singly linked list classpublic cl.pdf
Solve using java and using this Singly linked list classpublic cl.pdfaloeplusint
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfforladies
 
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docxreverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docxacarolyn
 
In this lab, you will be given a simple code for a min Heap, and you.pdf
In this lab, you will be given a simple code for a min Heap, and you.pdfIn this lab, you will be given a simple code for a min Heap, and you.pdf
In this lab, you will be given a simple code for a min Heap, and you.pdfcharanjit1717
 
Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Andrey Akinshin
 
Implement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdfImplement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdfSIGMATAX1
 
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfPROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfclimatecontrolsv
 
Link list part 2
Link list part 2Link list part 2
Link list part 2Anaya Zafar
 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdfafgt2012
 
import java-util--- public class MyLinkedList{ public static void.pdf
import java-util---  public class MyLinkedList{    public static void.pdfimport java-util---  public class MyLinkedList{    public static void.pdf
import java-util--- public class MyLinkedList{ public static void.pdfasarudheen07
 
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
 #ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf #ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdfangelsfashion1
 
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxlab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxDIPESH30
 
import javautilQueue import javautilLinkedList import .pdf
import javautilQueue import javautilLinkedList import .pdfimport javautilQueue import javautilLinkedList import .pdf
import javautilQueue import javautilLinkedList import .pdfADITIEYEWEAR
 

Similar to Help explain the code with line comments public class CompletedLis.pdf (20)

Implement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdfImplement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
 
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfHelp please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
 
Solve using java and using this Singly linked list classpublic cl.pdf
Solve using java and using this Singly linked list classpublic cl.pdfSolve using java and using this Singly linked list classpublic cl.pdf
Solve using java and using this Singly linked list classpublic cl.pdf
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
 
137 Lab-2.2.pdf
137 Lab-2.2.pdf137 Lab-2.2.pdf
137 Lab-2.2.pdf
 
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docxreverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
 
Lab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdfLab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdf
 
In this lab, you will be given a simple code for a min Heap, and you.pdf
In this lab, you will be given a simple code for a min Heap, and you.pdfIn this lab, you will be given a simple code for a min Heap, and you.pdf
In this lab, you will be given a simple code for a min Heap, and you.pdf
 
Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?
 
Implement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdfImplement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdf
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Linked lists
Linked listsLinked lists
Linked lists
 
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfPROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
 
Link list part 2
Link list part 2Link list part 2
Link list part 2
 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf
 
import java-util--- public class MyLinkedList{ public static void.pdf
import java-util---  public class MyLinkedList{    public static void.pdfimport java-util---  public class MyLinkedList{    public static void.pdf
import java-util--- public class MyLinkedList{ public static void.pdf
 
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
 #ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf #ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
 
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxlab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
 
import javautilQueue import javautilLinkedList import .pdf
import javautilQueue import javautilLinkedList import .pdfimport javautilQueue import javautilLinkedList import .pdf
import javautilQueue import javautilLinkedList import .pdf
 

More from almonardfans

1.For the standard (reference) SpMV algorithm, does the communicatio.pdf
1.For the standard (reference) SpMV algorithm, does the communicatio.pdf1.For the standard (reference) SpMV algorithm, does the communicatio.pdf
1.For the standard (reference) SpMV algorithm, does the communicatio.pdfalmonardfans
 
1.Does ZeRO propose solution for memory- or compute-bounded problem.pdf
1.Does ZeRO propose solution for memory- or compute-bounded problem.pdf1.Does ZeRO propose solution for memory- or compute-bounded problem.pdf
1.Does ZeRO propose solution for memory- or compute-bounded problem.pdfalmonardfans
 
1.Early versions of Supply chain included physical distribution and .pdf
1.Early versions of Supply chain included physical distribution and .pdf1.Early versions of Supply chain included physical distribution and .pdf
1.Early versions of Supply chain included physical distribution and .pdfalmonardfans
 
1.A tee with 33 tips will be given, with three of them filled by�D.pdf
1.A tee with 33 tips will be given, with three of them filled by�D.pdf1.A tee with 33 tips will be given, with three of them filled by�D.pdf
1.A tee with 33 tips will be given, with three of them filled by�D.pdfalmonardfans
 
1.A person is said to have referent power over you to the extent tha.pdf
1.A person is said to have referent power over you to the extent tha.pdf1.A person is said to have referent power over you to the extent tha.pdf
1.A person is said to have referent power over you to the extent tha.pdfalmonardfans
 
1. �Son precisas y veraces las afirmaciones de marketing de Smiths .pdf
1. �Son precisas y veraces las afirmaciones de marketing de Smiths .pdf1. �Son precisas y veraces las afirmaciones de marketing de Smiths .pdf
1. �Son precisas y veraces las afirmaciones de marketing de Smiths .pdfalmonardfans
 
1. �Qu� ventajas y desventajas encontraron las primeras plantas que .pdf
1. �Qu� ventajas y desventajas encontraron las primeras plantas que .pdf1. �Qu� ventajas y desventajas encontraron las primeras plantas que .pdf
1. �Qu� ventajas y desventajas encontraron las primeras plantas que .pdfalmonardfans
 
1.2 Practice (SOA Sample Q127) A company owes 500 and 1,000 to be pa.pdf
1.2 Practice (SOA Sample Q127) A company owes 500 and 1,000 to be pa.pdf1.2 Practice (SOA Sample Q127) A company owes 500 and 1,000 to be pa.pdf
1.2 Practice (SOA Sample Q127) A company owes 500 and 1,000 to be pa.pdfalmonardfans
 
1. �Qu� evento convenci� a Netflix para cambiar a un servicio basado.pdf
1. �Qu� evento convenci� a Netflix para cambiar a un servicio basado.pdf1. �Qu� evento convenci� a Netflix para cambiar a un servicio basado.pdf
1. �Qu� evento convenci� a Netflix para cambiar a un servicio basado.pdfalmonardfans
 
1.. Todos los siguientes elementos han sido identificados como impor.pdf
1.. Todos los siguientes elementos han sido identificados como impor.pdf1.. Todos los siguientes elementos han sido identificados como impor.pdf
1.. Todos los siguientes elementos han sido identificados como impor.pdfalmonardfans
 
1.----A method which enables the user to specify conditions to displ.pdf
1.----A method which enables the user to specify conditions to displ.pdf1.----A method which enables the user to specify conditions to displ.pdf
1.----A method which enables the user to specify conditions to displ.pdfalmonardfans
 
1. �Cu�les son los seis pasos de un proceso de selecci�n de puestos .pdf
1. �Cu�les son los seis pasos de un proceso de selecci�n de puestos .pdf1. �Cu�les son los seis pasos de un proceso de selecci�n de puestos .pdf
1. �Cu�les son los seis pasos de un proceso de selecci�n de puestos .pdfalmonardfans
 
1.) Una mujer que tiene sangre tipo A positiva tiene una hija que es.pdf
1.) Una mujer que tiene sangre tipo A positiva tiene una hija que es.pdf1.) Una mujer que tiene sangre tipo A positiva tiene una hija que es.pdf
1.) Una mujer que tiene sangre tipo A positiva tiene una hija que es.pdfalmonardfans
 
1. �Cu�l es la diferencia entre una bacteria F + y una Hfr d. Las.pdf
1. �Cu�l es la diferencia entre una bacteria F + y una Hfr d. Las.pdf1. �Cu�l es la diferencia entre una bacteria F + y una Hfr d. Las.pdf
1. �Cu�l es la diferencia entre una bacteria F + y una Hfr d. Las.pdfalmonardfans
 
1. �Cu�les de las siguientes afirmaciones sobre los or�genes de la a.pdf
1. �Cu�les de las siguientes afirmaciones sobre los or�genes de la a.pdf1. �Cu�les de las siguientes afirmaciones sobre los or�genes de la a.pdf
1. �Cu�les de las siguientes afirmaciones sobre los or�genes de la a.pdfalmonardfans
 
1. �Cu�l es la relaci�n entre Enron y SOX La quiebra y el esc�n.pdf
1. �Cu�l es la relaci�n entre Enron y SOX La quiebra y el esc�n.pdf1. �Cu�l es la relaci�n entre Enron y SOX La quiebra y el esc�n.pdf
1. �Cu�l es la relaci�n entre Enron y SOX La quiebra y el esc�n.pdfalmonardfans
 
1.) Imagina tres puntos en un mapa topogr�fico que est�n ubicados en.pdf
1.) Imagina tres puntos en un mapa topogr�fico que est�n ubicados en.pdf1.) Imagina tres puntos en un mapa topogr�fico que est�n ubicados en.pdf
1.) Imagina tres puntos en un mapa topogr�fico que est�n ubicados en.pdfalmonardfans
 
1. �Qu� es la dominancia apical 2. �Cu�l es el papel de la auxina.pdf
1. �Qu� es la dominancia apical 2. �Cu�l es el papel de la auxina.pdf1. �Qu� es la dominancia apical 2. �Cu�l es el papel de la auxina.pdf
1. �Qu� es la dominancia apical 2. �Cu�l es el papel de la auxina.pdfalmonardfans
 
1. �Por qu� no hubo un plan de sucesi�n en Lakkard Leather Carl F.pdf
1. �Por qu� no hubo un plan de sucesi�n en Lakkard Leather Carl F.pdf1. �Por qu� no hubo un plan de sucesi�n en Lakkard Leather Carl F.pdf
1. �Por qu� no hubo un plan de sucesi�n en Lakkard Leather Carl F.pdfalmonardfans
 
1. �Por qu� la nube es importante para ciudades como Dubuque mientra.pdf
1. �Por qu� la nube es importante para ciudades como Dubuque mientra.pdf1. �Por qu� la nube es importante para ciudades como Dubuque mientra.pdf
1. �Por qu� la nube es importante para ciudades como Dubuque mientra.pdfalmonardfans
 

More from almonardfans (20)

1.For the standard (reference) SpMV algorithm, does the communicatio.pdf
1.For the standard (reference) SpMV algorithm, does the communicatio.pdf1.For the standard (reference) SpMV algorithm, does the communicatio.pdf
1.For the standard (reference) SpMV algorithm, does the communicatio.pdf
 
1.Does ZeRO propose solution for memory- or compute-bounded problem.pdf
1.Does ZeRO propose solution for memory- or compute-bounded problem.pdf1.Does ZeRO propose solution for memory- or compute-bounded problem.pdf
1.Does ZeRO propose solution for memory- or compute-bounded problem.pdf
 
1.Early versions of Supply chain included physical distribution and .pdf
1.Early versions of Supply chain included physical distribution and .pdf1.Early versions of Supply chain included physical distribution and .pdf
1.Early versions of Supply chain included physical distribution and .pdf
 
1.A tee with 33 tips will be given, with three of them filled by�D.pdf
1.A tee with 33 tips will be given, with three of them filled by�D.pdf1.A tee with 33 tips will be given, with three of them filled by�D.pdf
1.A tee with 33 tips will be given, with three of them filled by�D.pdf
 
1.A person is said to have referent power over you to the extent tha.pdf
1.A person is said to have referent power over you to the extent tha.pdf1.A person is said to have referent power over you to the extent tha.pdf
1.A person is said to have referent power over you to the extent tha.pdf
 
1. �Son precisas y veraces las afirmaciones de marketing de Smiths .pdf
1. �Son precisas y veraces las afirmaciones de marketing de Smiths .pdf1. �Son precisas y veraces las afirmaciones de marketing de Smiths .pdf
1. �Son precisas y veraces las afirmaciones de marketing de Smiths .pdf
 
1. �Qu� ventajas y desventajas encontraron las primeras plantas que .pdf
1. �Qu� ventajas y desventajas encontraron las primeras plantas que .pdf1. �Qu� ventajas y desventajas encontraron las primeras plantas que .pdf
1. �Qu� ventajas y desventajas encontraron las primeras plantas que .pdf
 
1.2 Practice (SOA Sample Q127) A company owes 500 and 1,000 to be pa.pdf
1.2 Practice (SOA Sample Q127) A company owes 500 and 1,000 to be pa.pdf1.2 Practice (SOA Sample Q127) A company owes 500 and 1,000 to be pa.pdf
1.2 Practice (SOA Sample Q127) A company owes 500 and 1,000 to be pa.pdf
 
1. �Qu� evento convenci� a Netflix para cambiar a un servicio basado.pdf
1. �Qu� evento convenci� a Netflix para cambiar a un servicio basado.pdf1. �Qu� evento convenci� a Netflix para cambiar a un servicio basado.pdf
1. �Qu� evento convenci� a Netflix para cambiar a un servicio basado.pdf
 
1.. Todos los siguientes elementos han sido identificados como impor.pdf
1.. Todos los siguientes elementos han sido identificados como impor.pdf1.. Todos los siguientes elementos han sido identificados como impor.pdf
1.. Todos los siguientes elementos han sido identificados como impor.pdf
 
1.----A method which enables the user to specify conditions to displ.pdf
1.----A method which enables the user to specify conditions to displ.pdf1.----A method which enables the user to specify conditions to displ.pdf
1.----A method which enables the user to specify conditions to displ.pdf
 
1. �Cu�les son los seis pasos de un proceso de selecci�n de puestos .pdf
1. �Cu�les son los seis pasos de un proceso de selecci�n de puestos .pdf1. �Cu�les son los seis pasos de un proceso de selecci�n de puestos .pdf
1. �Cu�les son los seis pasos de un proceso de selecci�n de puestos .pdf
 
1.) Una mujer que tiene sangre tipo A positiva tiene una hija que es.pdf
1.) Una mujer que tiene sangre tipo A positiva tiene una hija que es.pdf1.) Una mujer que tiene sangre tipo A positiva tiene una hija que es.pdf
1.) Una mujer que tiene sangre tipo A positiva tiene una hija que es.pdf
 
1. �Cu�l es la diferencia entre una bacteria F + y una Hfr d. Las.pdf
1. �Cu�l es la diferencia entre una bacteria F + y una Hfr d. Las.pdf1. �Cu�l es la diferencia entre una bacteria F + y una Hfr d. Las.pdf
1. �Cu�l es la diferencia entre una bacteria F + y una Hfr d. Las.pdf
 
1. �Cu�les de las siguientes afirmaciones sobre los or�genes de la a.pdf
1. �Cu�les de las siguientes afirmaciones sobre los or�genes de la a.pdf1. �Cu�les de las siguientes afirmaciones sobre los or�genes de la a.pdf
1. �Cu�les de las siguientes afirmaciones sobre los or�genes de la a.pdf
 
1. �Cu�l es la relaci�n entre Enron y SOX La quiebra y el esc�n.pdf
1. �Cu�l es la relaci�n entre Enron y SOX La quiebra y el esc�n.pdf1. �Cu�l es la relaci�n entre Enron y SOX La quiebra y el esc�n.pdf
1. �Cu�l es la relaci�n entre Enron y SOX La quiebra y el esc�n.pdf
 
1.) Imagina tres puntos en un mapa topogr�fico que est�n ubicados en.pdf
1.) Imagina tres puntos en un mapa topogr�fico que est�n ubicados en.pdf1.) Imagina tres puntos en un mapa topogr�fico que est�n ubicados en.pdf
1.) Imagina tres puntos en un mapa topogr�fico que est�n ubicados en.pdf
 
1. �Qu� es la dominancia apical 2. �Cu�l es el papel de la auxina.pdf
1. �Qu� es la dominancia apical 2. �Cu�l es el papel de la auxina.pdf1. �Qu� es la dominancia apical 2. �Cu�l es el papel de la auxina.pdf
1. �Qu� es la dominancia apical 2. �Cu�l es el papel de la auxina.pdf
 
1. �Por qu� no hubo un plan de sucesi�n en Lakkard Leather Carl F.pdf
1. �Por qu� no hubo un plan de sucesi�n en Lakkard Leather Carl F.pdf1. �Por qu� no hubo un plan de sucesi�n en Lakkard Leather Carl F.pdf
1. �Por qu� no hubo un plan de sucesi�n en Lakkard Leather Carl F.pdf
 
1. �Por qu� la nube es importante para ciudades como Dubuque mientra.pdf
1. �Por qu� la nube es importante para ciudades como Dubuque mientra.pdf1. �Por qu� la nube es importante para ciudades como Dubuque mientra.pdf
1. �Por qu� la nube es importante para ciudades como Dubuque mientra.pdf
 

Recently uploaded

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 

Recently uploaded (20)

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 

Help explain the code with line comments public class CompletedLis.pdf

  • 1. Help explain the code with line comments public class CompletedList implements ListADT, Iterable { //Three instance variables protected int count; protected int modChange; protected DoubleLinearNode head, tail; //head and tail set to empty count set to zero public CompletedList() { head = tail = null; count = 0; } //Override for head and tail, remove first number of list @Override public T removeFirst() throws NoSuchElementException { //if head is empty return error if(isEmpty()) throw new NoSuchElementException("The collection is empty"); //Temp for each number set to head item T temp = head.getItem(); //if first number equals last they are null if(head == tail) { head = tail = null; } //else the ne else if(head.getNext() == tail) { head.remove(); head = tail; } else {
  • 2. head = head.getNext(); head.getPrev().remove(); } count--; modChange++; return temp; } @Override public T removeLast() throws NoSuchElementException { if(isEmpty()) throw new NoSuchElementException("The collection is empty"); T temp = tail.getItem(); if(head == tail) { head = tail = null; } else if(head.getNext() == tail){ tail.remove(); tail = head; } else { tail = tail.getPrev(); tail.getNext().remove(); } count--; modChange++; return temp; } @Override public T remove( T element ) { if(isEmpty())
  • 3. throw new NoSuchElementException("The target is not in the collection"); if(tail.getItem().equals(element)) { return removeLast(); } for (DoubleLinearNode current = head; current != null; current = current.getNext()) { if(current.getItem().equals(element)) { if(current == head) { return removeFirst(); } else { count--; modChange++; return current.remove(); } } } throw new NoSuchElementException("The target is not in the collection"); } @Override public T first() { if (isEmpty()) throw new NoSuchElementException("The collection is empty"); return head.getItem(); } @Override public T last() { if (isEmpty())
  • 4. throw new NoSuchElementException("The collection is empty"); return tail.getItem(); } @Override public boolean contains( T target ) { if(isEmpty()) return false; if(tail.getItem().equals(target)) { return true; } for (DoubleLinearNode current = head; current != null; current = current.getNext()) { if(current.getItem().equals(target)) { return true; } } return false; } @Override public boolean isEmpty() { return count == 0; } @Override public int size() { return count; } @Override
  • 5. public Iterator iterator() { return new ListIterator(head); } @Override public String toString() { StringBuilder sb = new StringBuilder(); for (DoubleLinearNode current = head; current != null; current = current.getNext()) { sb.append(current.getItem()).append(' '); } return sb.toString(); } private class ListIterator implements Iterator { private DoubleLinearNode current; private int modNum; public ListIterator( DoubleLinearNode node) { this.modNum = modChange; this.current = node; } @Override public boolean hasNext() { if(this.modNum != modChange) throw new ConcurrentModificationException("The collection has been modified!"); if(this.current != null) { return this.current.getNext() != null; } else
  • 6. { return false; } } @Override public T next() { if (!this.hasNext()) throw new NoSuchElementException(); this.current = this.current.getNext(); return this.current.getItem(); } @Override public void remove() { if(current == head) { modNum++; removeFirst(); current = head; } else if(current == tail) { modNum++; removeLast(); current = tail; } else { modNum++; modChange++; current = current.getNext(); current.getPrev().remove(); } }
  • 7. } }