Question Details

[solution] » URGENT PLEASE The overview is given and the instruction of the

Brief item decscription

Step-by-step solution file


Item details:

URGENT PLEASE The overview is given and the instruction of the
More:

URGENT PLEASE 

The overview is given and the instruction of the project is given on the Design 


import java.util.Iterator;

 

import java.util.ConcurrentModificationException;

 

import java.util.NoSuchElementException;

 

public class DoublyLinkedList<AnyType> implements List<AnyType>

 

{

 

private static class Node<AnyType>

 

{

 

private AnyType data;

 

private Node<AnyType> prev;

 

private Node<AnyType> next;

 

public Node(AnyType d, Node<AnyType> p, Node<AnyType> n)

 

{

 

setData(d);

 

setPrev(p);

 

setNext(n);

 

}

 

public AnyType getData() { return data; }

 

public void setData(AnyType d) { data = d; }

 

public Node<AnyType> getPrev() { return prev; }

 

public void setPrev(Node<AnyType> p) { prev = p; }

 

public Node<AnyType> getNext() { return next; }

 

public void setNext(Node<AnyType> n) { next = n; }

 

}

 

private

 

private

 

private

 

private int theSize;

 

int modCount;

 

Node<AnyType> header;

 

Node<AnyType> trailer; public DoublyLinkedList()

 

{

 

header = new Node<AnyType>(null, null, null);

 

trailer = new Node<AnyType>(null, null, null);

 

modCount = 0;

 

clear();

 

}

 

public void clear()

 

{

 

header.setNext(trailer);

 

trailer.setPrev(header);

 

theSize = 0;

 

}

 

public int size()

 

{

 

return theSize;

 

}

 

public boolean isEmpty()

 

{

 

return (size() == 0);

 

}

 

public AnyType get(int index)

 

{ } // Write code here to implement this method. public AnyType set(int index, AnyType newValue)

 

{

 

// Write code here to implement this method.

 

}

 

public boolean add(AnyType newValue)

 

{

 

add(size(), newValue);

 

return true;

 

}

 

public void add(int index, AnyType newValue)

 

{

 

// Write code here to implement this method.

 

}

 

public AnyType remove(int index)

 

{

 

return remove(getNode(index));

 

}

 

public Iterator<AnyType> iterator()

 

{

 

return new LinkedListIterator();

 

}

 

private Node<AnyType> getNode(int index)

 

{

 

return (getNode(index, 0, size()-1));

 

}

 

private Node<AnyType> getNode(int index, int lower, int upper)

 

{

 

// Write code here to implement this method.

 

}

 

private AnyType remove(Node<AnyType> currNode)

 

{

 

// Write code here to implement this method.

 

}

 

private class LinkedListIterator implements Iterator<AnyType>

 

{

 

private Node<AnyType> current;

 

private int expectedModCount;

 

private boolean okToRemove;

 

LinkedListIterator()

 

{

 

current = header.getNext();

 

expectedModCount = modCount;

 

okToRemove = false;

 

}

 

public boolean hasNext()

 

{

 

return (current != trailer);

 

}

 

public AnyType next()

 

{ if (modCount != expectedModCount)

 

throw new ConcurrentModificationException();

 

if (!hasNext())

 

throw new NoSuchElementException(); } AnyType nextValue = current.getData();

 

current = current.getNext();

 

okToRemove = true;

 

return nextValue; public void remove()

 

{

 

if (modCount != expectedModCount)

 

throw new ConcurrentModificationException();

 

if (!okToRemove)

 

throw new IllegalStateException(); }

 

} } DoublyLinkedList.this.remove(current.getPrev());

 

expectedModCount++;

 

okToRemove = false;

 







About this question:
STATUS
Answered
QUALITY
Approved
ANSWER RATING

This question was answered on: Feb 21, 2020

PRICE: $24

Solution~00066225621.zip (18.37 KB)

Buy this answer for only: $24

This attachment is locked

We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free copy (Deadline assured. Flexible pricing. TurnItIn Report provided)

Pay using PayPal (No PayPal account Required) or your credit card. All your purchases are securely protected by PayPal.
SiteLock

Need a similar solution fast, written anew from scratch? Place your own custom order

We have top-notch tutors who can help you with your essay at a reasonable cost and then you can simply use that essay as a template to build your own arguments. This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student. New solution orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.

Order Now