系列: Angelia
java
26 行
· 更新於 2026-09-27
SimpleList.java
Angelia/Java/Week_6_7/code/02_adt_interfaces/SimpleList.java
/**
* 最經典的 ADT:List(串列)。
*
* 串列是「有順序」的集合(有第一個、第二個……),允許重複,且大小可以改變
* ——「大小可變」正是串列與陣列最大的差別。
*
* 注意:這裡的元素型別是 Object(任何物件都能放);
* 第 7 章會用「泛型」把它升級成 SimpleList<T>。
*/
public interface SimpleList {
/** @return 串列中元素的個數 */
int size();
/**
* @param index 前置條件:0 <= index < size()
* @return 第 index 個元素(從 0 起算)
*/
Object get(int index);
/** 把 o 加到串列尾端。後置條件:size() 增加 1 */
void add(Object o);
/** 移除第一個與 o 相等(equals)的元素;若不存在則什麼都不做。 */
void remove(Object o);
}
相關文章
Angelia
haskell
EN
更新於 2026-02-03
Adding.hs
Adding.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Adding.hs).
閱讀文章 →
Angelia
haskell
EN
更新於 2026-02-03
Area.hs
Area.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Area.hs).
閱讀文章 →
Angelia
haskell
EN
更新於 2026-02-03
Chess.hs
Chess.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Chess.hs).
閱讀文章 →
Angelia
haskell
EN
更新於 2026-02-03
ChessGraphics.hs
ChessGraphics.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/ChessGraphics.hs).
閱讀文章 →
Angelia
haskell
EN
更新於 2026-02-03
Examples.hs
Examples.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Examples.hs).
閱讀文章 →
Angelia
haskell
EN
更新於 2026-02-03
Fibonacci.hs
Fibonacci.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Fibonacci.hs).
閱讀文章 →