Class SearchedItemsLinkedList
java.lang.Object
org.troy.capstone.data_structures.SearchedItemsLinkedList
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classPrivate inner class representing a node in the linked list. -
Field Summary
FieldsModifier and TypeFieldDescriptionThe current node in the linked list, representing the current page of search results.The head node of the linked list.private static final intThe number of items to display per page.private intThe total number of pages in the linked list, calculated based on the total number of items and items per page. -
Constructor Summary
ConstructorsConstructorDescriptionSearchedItemsLinkedList(ItemRepo itemRepo, List<String> itemIdList) Constructor forSearchedItemsLinkedList. -
Method Summary
Modifier and TypeMethodDescriptiongetHead()Returns the list of items in the head node of the linked list.getNext()Returns the list of items in the next node of the linked list.intReturns the total number of pages in the linked list.Returns the list of items in the previous node of the linked list.
-
Field Details
-
head
The head node of the linked list. -
current
The current node in the linked list, representing the current page of search results. -
ITEMS_PER_PAGE
private static final int ITEMS_PER_PAGEThe number of items to display per page.- See Also:
-
pageCount
private int pageCountThe total number of pages in the linked list, calculated based on the total number of items and items per page.
-
-
Constructor Details
-
SearchedItemsLinkedList
Constructor forSearchedItemsLinkedList. 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:
itemReposhould contain valid item data for all item IDs initemIdList, anditemIdListshould 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
-
getNext
-
getPrevious
-