04.ARRAY-BASED LIST

SYNTAX

DEFINITIONS

LIST

  • a collection of elements of the same type

    • because all the elements of a list are of the same type, they will be stored in an array

  • the length of a list is the number of elements in the list

  • to process a list in an array, the following variables are required

    • the array holding the list elements (a pointer)

    • a variable to store the length of the list (the number of list elements currently in the array)

    • a variable to store the size of the array (the maximum number of elements that can be stored in the array

LIST OPERATIONS

  • create the list. the list is initialized to any empty state (constructor)

  • determine whether the list is empty (check the length)

  • determine whether the list is full (compare the length with the size

  • find the size of the list

  • destroy, or clear the list (destructor or a user-defined function)

  • insert an item at a given position

  • search the list for a given item

TEMPLATE

  • a collection of elements of generic type

ARRAY-BASED LIST IMPLEMENTATION

UML

  • The negative sign (-) signifies that the member variables are private

  • The positive sign (+) signifies that the member functions are public

  • The hash symbol (#) signifies that the member variables are protected

SOURCE CODE

HEADER FILE: arrayListDesign.h

HEADER FILE: arrayListImplementation.h

SOURCE FILE: implementation.cpp

Last updated