The
MasterLinkedList
class manages a linked list of line-linked-lists, where each node contains the data of a whole line-linked-list.
HEAD
Pointer: TheHEAD
is the common name for the pointer indicates to the first node in the linked list. serves as the entry point or starting node of the linked list.
LineLinkedList()
: Initializes an empty linked list with a nullHEAD
pointer.
-
isEmpty()
:- Checks if the linked list is empty by checking the
HEAD
pointer. - If the HEAD pointer is
nullptr
, indicating the initialized value and the absence of nodes, the method returns true, otherwise, it returns false.
- Checks if the linked list is empty by checking the
-
insertLine(string *words, int count)
:- Inserts a line into the linked list, it receives an array of words and then enter all the receiveed words inside a single node.
- Parameters:
words
: A pointer to an array of strings containing the words in the line.count
: The number of words in the line.
-
getLinesCount()
:- Returns the total number of lines in the linked list.
-
display()
:- Displays all the lines stored in the linked list.
-
displayByLineIndex(int index)
:- Displays the line at the specified index in the linked list.
- Parameters:
index
: The index of the line to display.
-
searchByWord(string key)
:- Searches for a word in the lines and prints if it's found.
- Parameters:
key
: Is the word that the function search for.
-
searchByWordAndLine(int lineIndex, int wordIndex)
:- Searches for a word at a specific position in a specific line and prints it.
- Parameters:
lineIndex
: The index of the line that the word will be searched in.wordIndex
: The index of the word in thelineIndex
that the word will be searched in.
-
getLettersCountByWordIndex(int index)
:- Returns the number of letters in a line at a specific index.
- Parameters:
index
: The index of the word.
-
getLettersCount()
:- Returns the total number of letters in all lines.
-
getWordsCount(int lineIndex)
:- Returns the total number of words in a specific line.
- lineIndex:
index
: The index of the line.
- Can lines be inserted at any position in the list?
- Yes, lines can be inserted at the end of the list. The
insertLine()
function appends a new line to the end of the linked list, ensuring that lines are added in sequential order.
- Yes, lines can be inserted at the end of the list. The