binibiningtinamoran

HeadTailListInterface

May 27th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.08 KB | None | 0 0
  1. public interface HeadTailListInterface<T>
  2. {
  3.     /**
  4.      * Adds a new entry to the beginning of this list. Entries currently in
  5.      * the list are shifted down. The size of this list is increased by 1.
  6.      *
  7.      * @param newEntry The object to be added as a new entry.
  8.      *
  9.      * @throws ClassCastException if the class of the new entry
  10.      * prevents it from being added to this list.
  11.      *
  12.      * @throws IllegalArgumentException - if some property of the new entry
  13.      * prevents it from being added to this list.
  14.      */
  15.     public void addFront(T newEntry);
  16.  
  17.     /**
  18.      * Adds a new entry to the end of this list. Entries currently in this
  19.      * list are unaffected. The size of this list is increased by 1.
  20.      *
  21.      * @param newEntry The object to be added as a new entry.
  22.      *
  23.      * @throws ClassCastException if the class of the new entry prevents it
  24.      * from being added to this list.
  25.      *
  26.      * @throws IllegalArgumentException if some property of the new entry
  27.      * prevents it from being added to this list.
  28.      */
  29.     public void addBack(T newEntry);
  30.  
  31.     /**
  32.      * Removes the entry from the beginning of this list. Other
  33.      * entries' indices are shifted up. The size of this list is
  34.      * decreased by 1.
  35.      *
  36.      * @return The reference to the entry that was removed or null if this
  37.      * list is empty
  38.      */
  39.     public T removeFront();
  40.  
  41.     /**
  42.      * Removes the entry from the end of this list. Other entries
  43.      * currently in this list are unaffected. The size of this list is
  44.      * decreased by 1.
  45.      *
  46.      * @return The reference to the entry that was removed or null if this list
  47.      * is empty.
  48.      */
  49.     public T removeBack();
  50.  
  51.     /**
  52.      * Retrieves the entry at a given position in this list.
  53.      * @param position an integer indicative of the position of the entry.
  54.      *
  55.      * @return The reference to the retrieved entry based on the given position.
  56.      * Cannot be null.
  57.      *
  58.      * @throws IndexOutOfBoundsException if position is negative or greater
  59.      * than the length of this list.
  60.      */
  61.     public T getEntry(int position);
  62.  
  63.     /**
  64.      * Displays all of the entries in this list, in the order in which they
  65.      * occur in this list.
  66.      */
  67.     public void display();
  68.  
  69.     /**
  70.      * Searches for a specific entry in this list.
  71.      *
  72.      * @param entry The object to be searched for.
  73.      *
  74.      * @return The position of the entry that was found or -1 if the entry is
  75.      * not found.
  76.      */
  77.     //@throws ClassCastException if the type of the specified element is
  78.     //     * incompatible with this list
  79.     public int contains(T entry);
  80.  
  81.     /** Detects whether this list is empty.
  82.      *
  83.      * @return True if this list contains no elements, false otherwise.
  84.      */
  85.     public boolean isEmpty();
  86.  
  87.     /**
  88.      * Detects the number of elements in this list.
  89.      *
  90.      * @return The integer number of entries currently in this list.
  91.      */
  92.     public int size();
  93.  
  94.     /**
  95.      * Removes all entries in this list.
  96.      */
  97.     public void clear();
  98. }
Advertisement
Add Comment
Please, Sign In to add comment