namespace DataStructures
{
public interface IDS<T>
{
int Count { get; } // 取得長度
void Clear(); // 清空
bool IsEmpty { get; } // 判斷是否為空
}
}
namespace DataStructures.Lists
{
public interface IListDS<T> : IDS<T>
{
void Append(T item); // 尾部新增
void Insert(T item, int index); // 指定位置插入
T Delete(int index); // 刪除並回傳
T GetElement(int index); // 取得元素
int Locate(T value); // 按值查找索引
}
}
統一定義各資料結構共同操作,利於多型與程式碼重用。