![](https://csdnimg.cn/release/download_crawler_static/20923278/bg9.jpg)
第
9
页
State_code remove(int position, List_entry& x);
State_code insert(int position, const List_entry& x);
State_code insert_first(const List_entry& x, List& a_list);
State_code remove_first(List_entry& x, List& a_list);
State_code insert_last(const List_entry& x, List& a_list);
State_code remove_last(List_entry& x, List& a_list);
State_code median_list(List_entry& x, List& a_list);
protected:
// data members for a contiguous list implementation
int count;
List_entry entry[max_list];
};
template <class List_entry>List<List_entry>::List()
{
count = 0;
}
template <class List_entry>int List<List_entry>::size() const
{
return count;
}
template <class List_entry>bool List<List_entry>::full() const
{
return count == max_list;
}
template <class List_entry>bool List<List_entry>::empty() const
{
return count == 0;
}
template <class List_entry>void List<List_entry>::clear()
{
count = 0;
}
template <class List_entry>void List<List_entry>::traverse(void (*visit)(List_entry&))
{
for (int i = 0; i < count; i++)
(*visit)(entry[i]);
}
template <class List_entry>State_code List<List_entry>::retrieve(int position,
List_entry& x) const
{
if (position < 0 || position >= count)
return range;
x = entry[position];
return success;