Building a List ADT
A list is a sequence of items with similar data types, where the order of the item's position matters.There are several common operations that are available in a List ADT, and they are:
Get(i)
, which will return the value of selected index,Âi
. If theÂi
 index is out of bounds, it will simply returnÂ-1
.Insert(i, v)
, which will insert thev
value at the position of indexÂi
.Search(v)
, which will return the index of the first occurrence ofÂv
 (if theÂv
 value doesn't exist, the return value isÂ-1
).Remove(i)
, which will remove the item in thei
index.Â
Note
For simplicity, we are going to build a List ADT that accepts int
data only, from zero (0) and higher.Â
Now, by using the array data type we discussed earlier, let's build a new ADT named List
which contains the preceding operations. We need two variables to hold the list of items (m_items
) and the number of items in the list (m_count
). We will make them private
so that it cannot be accessed from the outside class. All four operations...