bool List empty const Post: The function returns true or false according to whether the List is empty or not. bool List: fullo const Post: The function returns true or false according to whether the list is full or not int List size const; Post: The function returns the number of entries in the list
bool List :: empty() const; Post: The function returns true or false according to whether the List is empty or not. bool List :: full() const; Post: The function returns true or false according to whether the List is full or not. int List :: size() const; Post: The function returns the number of entries in the List
Position Number in a list To find an entry in a list, we use an integer that gives its position within the list We shall number the positions in a list so that the first entry in the list has position 0, the second position 1, and soon。 Locating an entry of a list by its position is superficially ike indexing an array, but there are important differences. If we insert an entry at a particular position, then the position numbers of all later entries increase by 1. If we remove an entry, then the positions of all following entries decrease by 1
Position Number in a List ◆To find an entry in a list, we use an integer that gives its position within the list. ◆We shall number the positions in a list so that the first entry in the list has position 0, the second position 1, and so on. ◆Locating an entry of a list by its position is superficially like indexing an array, but there are important differences. If we insert an entry at a particular position, then the position numbers of all later entries increase by 1. If we remove an entry, then the positions of all following entries decrease by 1
The position number for a list is defined without regard to the implementation. For a contiguous list implemented in an array the position will indeed be the index of the entry within the array but we will also use the position to find an entry within linked implementations of a list, where no indices or arrays are used at all
◆The position number for a list is defined without regard to the implementation. For a contiguous list, implemented in an array, the position will indeed be the index of the entry within the array. But we will also use the position to find an entry within linked implementations of a list, where no indices or arrays are used at all
Error code List: insert(int position, const List entry &x); Post: If the List is not full and o position n, where n is the number of entries in the List, the function succeeds: Any entry formerly at position and all later entries have their position numbers increased by 1, and x is inserted at position in the list Else: The function fails with a diagnostic error code
Error_code List::insert(int position, const List_entry &x); Post: If the List is not full and 0 position n, where n is the number of entries in the List, the function succeeds:Any entry formerly at position and all later entries have their position numbers increased by 1, and x is inserted at position in the List. Else: The function fails with a diagnostic error code
Error_code List: remove( int position, List entry &x Post: If 0 s position <n where n is the number of entries in the list, the function succeeds: the entry at position is removed from the list, and all later entries have their position numbers decreased by 1. The parameter x records a copy of the entry formerly at position Else: The function fails with a diagnostic error code
Error_code List :: remove ( int position, List_entry &x ); Post: If 0 ≤ position<n, where n is the number of entries in the List, the function succeeds: The entry at position is removed from the List, and all later entries have their position numbers decreased by 1. The parameter x records a copy of the entry formerly at position. Else: The function fails with a diagnostic error code