五.
}
};
};
template
class WriteList
{
LIST& m_list;
public:
typedef typename LIST::value_type value_type;
typedef typename LIST::size_type size_type;
typedef typename LIST::difference_type difference_type;
typedef typename LIST::reference reference;
typedef typename LIST::const_reference const_reference;
typedef typename LIST::pointer pointer;
typedef typename LIST::const_pointer const_pointer;
WriteList(LIST& l): m_list(l)
{
}
void push_back(const_reference data)
{
m_list.push_back(data);
}
bool empty()
{
return m_list.empty();
}
size_type size()
{
return m_list.size();
}
size_type buffer_size()
{
return m_list.buffer_size();
}
};
template
class ReadList
{
LIST& m_list;
public:
typedef typename LIST::value_type value_type;
typedef typename LIST::size_type size_type;
typedef typename LIST::difference_type difference_type;
typedef typename LIST::reference reference;
typedef typename LIST::const_reference const_reference;
typedef typename LIST::pointer pointer;
typedef typename LIST::const_pointer const_pointer;
ReadList(LIST& l): m_list(l)
{
}
void pop_front()
{
m_list.pop_front();
}
reference front()
{
return m_list.front();
}
const_reference front() const
{
return m_list.front();
}
bool empty()
{
return m_list.empty();
}
size_type size()
{
return m_list.size();
}
size_type buffer_size()
{
return m_list.buffer_size();
}
};
#endif
}
};
};
template
class WriteList
{
LIST& m_list;
public:
typedef typename LIST::value_type value_type;
typedef typename LIST::size_type size_type;
typedef typename LIST::difference_type difference_type;
typedef typename LIST::reference reference;
typedef typename LIST::const_reference const_reference;
typedef typename LIST::pointer pointer;
typedef typename LIST::const_pointer const_pointer;
WriteList(LIST& l): m_list(l)
{
}
void push_back(const_reference data)
{
m_list.push_back(data);
}
bool empty()
{
return m_list.empty();
}
size_type size()
{
return m_list.size();
}
size_type buffer_size()
{
return m_list.buffer_size();
}
};
template
class ReadList
{
LIST& m_list;
public:
typedef typename LIST::value_type value_type;
typedef typename LIST::size_type size_type;
typedef typename LIST::difference_type difference_type;
typedef typename LIST::reference reference;
typedef typename LIST::const_reference const_reference;
typedef typename LIST::pointer pointer;
typedef typename LIST::const_pointer const_pointer;
ReadList(LIST& l): m_list(l)
{
}
void pop_front()
{
m_list.pop_front();
}
reference front()
{
return m_list.front();
}
const_reference front() const
{
return m_list.front();
}
bool empty()
{
return m_list.empty();
}
size_type size()
{
return m_list.size();
}
size_type buffer_size()
{
return m_list.buffer_size();
}
};
#endif
本文介绍了一种基于模板类实现的读写列表结构。该结构通过两个模板类`WriteList`和`ReadList`来提供对列表的操作,包括添加元素、删除元素等基本功能,并提供了检查列表是否为空及获取列表大小的方法。
361

被折叠的 条评论
为什么被折叠?



