Search:

Type: Posts; User: javapenguin

Search: Search took 0.20 seconds.

  1. Replies
    23
    Views
    10,828

    Re: Generic Doubly Linked List

    It seems that my remove() method didn't correct the previous references. I kinda need this class again for another assignment, which is going to be a total nightmare. Also my code for...
  2. Replies
    23
    Views
    10,828

    Re: Generic Doubly Linked List

    Ok, I think I fixed the get() method so it works.

    However, what's wrong with the remove method? Wait, maybe nothing is after all, but what about the alternateString()?
  3. Replies
    23
    Views
    10,828

    Re: Generic Doubly Linked List

    public void remove(int index)
    {
    if ((index<0) || (index>=size))
    {
    JOptionPane.showMessageDialog(null, "You cannot remove an out-of-bounds value!", "Invalid removal",...
  4. Replies
    23
    Views
    10,828

    Re: Generic Doubly Linked List

    What if the list is of size 1 or greater before you add anything?

    Adding it to size 1 should make head = newNode and tail = oldHead;

    adding to size 2 or greater should make new node head and...
  5. Replies
    23
    Views
    10,828

    Re: Generic Doubly Linked List

    Now my addFirst() is busted!
    ~X(~X(~X(:-s:-s^:)^^:)^b-(b-(:-o:-<[-O<:((>:D<#-o

    What's wrong now?

    public void addFirst(T data)
    {
    // Node<T> newnode = new Node<T>(data,head,...
  6. Replies
    23
    Views
    10,828

    Re: Generic Doubly Linked List

    package Assignment4;

    import javax.swing.JOptionPane;
    import java.util.*;
    import java.io.*;



    public class DoublyLinkedList<T>
    {
  7. Replies
    23
    Views
    10,828

    Re: Generic Doubly Linked List

    Thanks. However, what will it do with the value that was originally the tail? Does it automatically set the previous value to be be the old tail.

    like this:

    oldtail = newnode.previous;
    ...
  8. Replies
    23
    Views
    10,828

    Re: Generic Doubly Linked List

    Ok, but what does:


    public void addLast(T data)
    {
    Node<T> current;


    current = tail;
    if (tail == null)
  9. Replies
    23
    Views
    10,828

    Re: Generic Doubly Linked List

    ^:)^^:)^^:)^:-t:-t:-t:-t

    I thought head was the first Node in the list and tail was the last Node in the list. Was I wrong?

    In a list of size 5, head would certainly not be null. Unless I'm...
  10. Replies
    23
    Views
    10,828

    Re: Generic Doubly Linked List

    is my addLast() method doing this:

    1.) creating a Node current and setting it to tail

    2.) setting the tail to the value after current;

    3.) setting the old tail to the new tail.previous

    if...
  11. Replies
    23
    Views
    10,828

    Re: Generic Doubly Linked List

    No, it's not a circular list.

    package Assignment4;

    import javax.swing.JOptionPane;
    import java.util.*;
    import java.io.*;

    public class DoublyLinkedList<T>
    {
  12. Replies
    23
    Views
    10,828

    Re: Generic Doubly Linked List

    Yes, but for one, how do you modify the constructor to get it to work now with tail? tail could be null, or it could be head if size =1, or it could be anything else.

    My constructor is what's...
  13. Replies
    23
    Views
    10,828

    Re: Generic Doubly Linked List

    First off, how to fix the Node constructor now for each time I make a new Node.

    This code was changed from a SinglyLinkedList code:

    public class SinglyLinkedList<T>
    {
    private class Node<T>...
  14. Replies
    23
    Views
    10,828

    Generic Doubly Linked List

    I need to create a DoublyLinkedList class


    import javax.swing.JOptionPane;
    import java.util.*;
    import java.io.*;

    public class DoublyLinkedList<T>
    {
    private class Node<T>
Results 1 to 14 of 14