Class SearchedItemsLinkedList

java.lang.Object
org.troy.capstone.data_structures.SearchedItemsLinkedList

public class SearchedItemsLinkedList extends Object
The SearchedItemsLinkedList class represents a custom linked list data structure that organizes search results into pages. Each node in the linked list contains a list of items corresponding to a page of search results, and the list provides methods to navigate between pages.
  • Field Details

    • current

      The current node in the linked list, representing the current page of search results.
    • ITEMS_PER_PAGE

      private static final int ITEMS_PER_PAGE
      The number of items to display per page.
      See Also:
    • pageCount

      private int pageCount
      The total number of pages in the linked list, calculated based on the total number of items and items per page.
  • Constructor Details

    • SearchedItemsLinkedList

      public SearchedItemsLinkedList(ItemRepo itemRepo, List<String> itemIdList)
      Constructor for SearchedItemsLinkedList. Initializes the linked list based on a list of item IDs and an item repository.
      Parameters:
      itemRepo - The item repository containing all items, used to populate the linked list nodes based on the provided item IDs.
      itemIdList - The list of item IDs representing the search results to be organized into pages in the linked list.
      Preconditions:
      itemRepo should contain valid item data for all item IDs in itemIdList, and itemIdList should not be null.
  • Method Details

    • getPageCount

      public int getPageCount()
      Returns the total number of pages in the linked list.
      Returns:
      The total number of pages, calculated based on the total number of items and items per page.
    • getHead

      public List<Item> getHead()
      Returns the list of items in the head node of the linked list.
      Returns:
      The list of items in the head node, or null if the linked list is empty.
    • getNext

      public List<Item> getNext()
      Returns the list of items in the next node of the linked list.
      Returns:
      The list of items in the next node, or null if there is no next node.
      Postconditions:
      If there is a next node, the current node is advanced to the next node.
    • getPrevious

      public List<Item> getPrevious()
      Returns the list of items in the previous node of the linked list.
      Returns:
      The list of items in the previous node, or null if there is no previous node.
      Postconditions:
      If there is a previous node, the current node is moved to the previous node.