作者tinlans ( )
看板Programming
标题Re: [问题] 问一下有关ADT
时间Sat Feb 3 03:50:22 2007
※ 引述《bigbite (我爱陶吉吉)》之铭言:
: 究竟array算不算一种ADT呢??
: 虽然array为一群相同资料结构的元素,但是indexing却是一种抽象化的动作,
: 还是说array只是单纯的指一群资料的集合呢??
: 谢谢~~
在 general concept 上不是,
它只是一种 data representation,
属於 implement 的一种手段。
ADT 要求 spec 跟 implement 是独立的,
譬如今天你开了一个 stack 的 spec,
描述了需要哪些 objects 和 operations (这两项也是 ADT 定义要求),
你可以用 array (以及一些 ints 变数) 当 data representation,
以及对应的 operations 如 push()、pop() 等实作方式,
也可以用 linked list (以及一些 ints 变数) 当 data representation,
以及对应的 push()、pop() 等 operations 的另一套实作方式。
至於为什麽在 general concept 上不是,
这是因为需要设定一个底限,
如果 array 是 ADT,
因为没有比它更基础的 data representation 名称,
就算 spec 订出来也还是要拿它本身来实作自己,
所以不会这样归类。
有一些 languages or libraries 会故意根据 array 的 spec,
做一个也叫做 array 或 Array 的 class 出来,
这样的命名其实并不是很好,
为了避免混淆大部分会改名叫 vector,
这是因为通常在这个 class 之外,
还会存在一个也叫做 array 的基础语言设施。
PS. 上上段的 int 後面加上 s 通常表「泛整数型别」的简称。
--
Name: Tseng, Ling-hua E-mail Address:
[email protected]
School: National Tsing Hua University Department: Computer Science
Interesting: C++, Compiler, PL/PD, OS, VM, Large-scale software design
Researching: Software pipelining for VLIW architectures
Homepage:
https://it.muds.net/~uranus
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.230.220.28
※ 编辑: tinlans 来自: 61.230.220.28 (02/03 03:52)
1F:推 bigbite:感谢~~140.113.138.113 02/03 21:05