什么身子| 鞭挞是什么意思| 晨勃消失是什么原因| 例假是什么意思| 吃饭出汗是什么原因| 什么言| 故友是什么意思| vivo手机是什么牌子| 不长头发是什么原因| 狗肉不能和什么食物一起吃| 心跳过快是什么原因引起的| 2020年什么年| 农历五月十九是什么日子| 开户名是什么| 二本是什么学历| 小腿长痣代表什么意思| 雪纺是什么面料| 属虎的幸运色是什么颜色| 打嗝吃什么中成药| 俄罗斯信奉什么教| 斑斓什么意思| 96年是什么年| 干眼症用什么药| 恨不相逢未嫁时什么意思| 我想长胖点有什么办法| 周杰伦什么学历| 动脉抽血为什么这么疼| 褪黑素有什么副作用| 西洋参不适合什么人吃| 孕早期失眠是什么原因| 顺铂是什么药| cj什么意思| 四离日是什么意思| 下巴下面长痣代表什么| 为什么白带是黄绿色的| 颜字五行属什么| 提高免疫力吃什么食物| 正月初一是什么生肖| 酸根是什么| 男人肾虚吃什么补得快| 人属于什么界门纲目科属种| 安全期是什么| 壁虎在家里是什么征兆| 太阳是什么颜色的| 女性尿道出血是什么原因引起的| 为什么睡久了会头疼| 福生无量是什么意思| cl是什么元素| 什么叫有氧运动和无氧运动| 为什么白带是黄绿色的| 苦荞茶喝了有什么好处| 等代表什么生肖| 睛可以组什么词| 体检报告都检查什么| 男人前列腺炎有什么症状表现| 红楼梦什么朝代| 症瘕痞块是什么意思| 沟壑什么意思| 杏花代表什么生肖| 正常人为什么会得梅毒| 风光秀丽的什么| 吃什么头发长的快| 谷丙转氨酶高吃什么药可以降下来| 经常发低烧是什么原因| 泉中水是什么生肖| 女人来月经吃什么好| 吃什么可以降血压| 四海是什么意思| 男性性功能减退吃什么药| 肝火旺盛是什么原因引起的| 桑叶有什么功效| 1937年是什么年| 舌根发黄是什么原因造成的| 宫颈多发纳氏囊肿是什么意思| 胃溃疡十二指肠溃疡吃什么药| 三点水一个兆读什么| 灰配什么颜色好看| penguin是什么意思| 猪儿虫是什么意思| 左肾小囊肿是什么意思| 低血压是什么| 动手术后吃什么对伤口恢复比较快| 王大锤真名叫什么| 树挪死人挪活是什么意思| 生姜什么时候种| 牛肉发绿色是什么原因| 什么是共情| 青春期指什么年龄段| 舌头上有裂纹是什么原因| 热量是什么意思| 来月经喝啤酒有什么影响| 脾是起什么作用的| 腹胀腹痛吃什么药| 鳌是什么意思| 无关风月是什么意思| 1882年属什么生肖| 山东特产是什么| 什么食物黄体酮含量高| 显现是什么意思| husky是什么牌子| 长期缺铁性贫血会导致什么后果| 什么情况需要打破伤风| 摆脱是什么意思| 同病相怜是什么意思| 女人胯骨疼是什么原因| 办理结婚证需要什么材料| 花痴病是什么症状| 狗狗气喘吃什么药| 什么时候跳绳减肥效果最好| 一抽一抽的打嗝叫什么| 单侧耳鸣是什么原因引起的| 多糖是什么意思| 铁观音什么季节喝最好| 渚是什么意思| 林子祥属什么生肖| 男的尿血是什么原因| 手掌横纹代表什么意思| 什么叫会车| 焦虑失眠吃什么药最好| 什么是pi| 美国人喜欢什么颜色| 是什么星座| 意外是什么意思| 米黄是什么颜色| 骶管囊肿是什么意思| 温柔的动物是什么生肖| 螃蟹不能跟什么一起吃| 苹果醋有什么好处| 超细旦是什么面料| 壁虎是什么类动物| 脾与什么相表里| 危险期是什么时候| 耳垂后面有痣代表什么| 孕酮低吃什么药| 什么是肺纤维化| 钙片什么时候吃| 6月13日是什么星座| 血小板偏高是什么意思| 弄得什么| 上不来气吃什么药| 床上出现蜈蚣什么原因| 小孩拉肚子吃什么药效果好| 泡果酒用什么酒好| 魅可口红属于什么档次| 诸葛亮属相是什么生肖| 红茶用什么茶具泡好| 泡脚出汗有什么好处| 孩子脾胃虚弱吃什么药| 拍ct挂什么科| p53阳性是什么意思| 鹰头皮带是什么牌子| 别字是什么意思| 1997年属什么生肖| 吃芒果不能和什么一起吃| 瓜蒌根为什么叫天花粉| 预防脑出血吃什么药| 脚心发麻是什么原因引起的| 血小板为什么会高| 痛风发作吃什么药| 子宫癌有什么症状| 什么人不能吃猪肝| 保肝护肝吃什么| pcp是什么意思| 什么是疣| 印堂跳动是什么预兆| 每天吃什么菜谱星期表| 室内用什么隔墙最便宜| ppm是什么| 甲亢有些什么症状| 乐果是什么农药| 汗疱疹用什么药膏最好| 食用酒精是什么做的| 睡觉经常流口水是什么原因| 胃火大吃什么药效果好| 看心脏病挂什么科| 心慌气短胸闷吃什么药| 肩周炎吃什么药好| 夜间胃痛是什么原因| 脚踝发黑是什么原因| 牙龈出血是什么病征兆| 胸闷气短吃什么药疗效比较好| 奇花初胎矞矞皇皇是什么意思| 梦见买黄金是什么兆头| 秋葵有什么营养价值| 大象吃什么食物| 益母草长什么样子图片| 鼻炎会引起什么症状| 脚后跟开裂用什么药| 理疗是什么| 猪八戒的武器叫什么| 一台什么| 什么犹如什么造句| 八仙过海指什么生肖| 自渡是什么意思| 中二病的意思是什么| 临床医学是什么| 孕吐喝什么水可以缓解| 亚麻籽油是什么植物的籽榨出来的| 屁股出血什么原因| 威士忌兑什么饮料好喝| 脂肪疝是什么病| 面诊是什么意思| 莘莘学子是什么意思| 李白字什么| 脂肪肝吃什么水果好| 海淘是什么意思啊| 小case什么意思| 糖尿病人吃什么水果| 胎监是检查什么的| 慢性鼻窦炎吃什么药| 侧重点是什么意思| 九牛一毛指什么生肖| 1月1日什么星座| modal是什么意思| 揩是什么意思| 香蕉吃多了有什么坏处| 无菌敷贴是干什么用的| 波推飞机什么意思| 陈皮有什么功效作用| 最大的荔枝是什么品种| 元气是什么| 做造影什么时候做最好| soe咖啡是什么意思| 催乳素过高会有什么严重的后果| 田野里有什么| 孩子鼻塞吃什么药| 眼什么手什么| 张五行属什么| 哇噻是什么意思| 拔牙吃什么消炎药| 面瘫吃什么药好| 天蝎什么象| 胆囊炎挂什么科室| 尿里面有血是什么原因| 三月三号是什么星座| 什么是寒性食物| 寄什么快递最便宜| 什么的草地| 当兵有什么要求| delsey是什么牌子| 什么时候用顿号| 舌头发白是什么原因| 笑靥如花是什么意思| 单侧耳鸣是什么原因引起的| 沙示汽水有什么功效| 岳飞是什么生肖| 肝硬化有什么症状| 继发性高血压什么意思| 腰间盘膨出和突出有什么区别| 白带发黄粘稠是什么原因| 咖啡拿铁是什么意思| 槟榔是什么东西| 外快是什么意思| 坐久了脚肿是什么原因| 决明子是什么东西| 夏天都有什么花| 咽炎咳嗽吃什么药| 拜阿司匹林什么时间吃最好| 病毒性肠胃炎吃什么药| 60岁属什么| 台风什么时候结束| 黄金是什么| 颞下颌关节紊乱挂什么科| 什么心什么目| 百度

[拉萨]拉萨常住人口个性化家庭医生签约率达92.3%

(Redirected from List (computer science))
百度 只是偶尔被狼堡逼着去当车模卖车,面对球队这样的安排,张稀哲只能用我服了,来表示自己的不满。

In computer science, a list or sequence is a collection of items that are finite in number and in a particular order. An instance of a list is a computer representation of the mathematical concept of a tuple or finite sequence.

A list may contain the same value more than once, and each occurrence is considered a distinct item.

A singly-linked list structure, implementing a list with three integer elements.

The term list is also used for several concrete data structures that can be used to implement abstract lists, especially linked lists and arrays. In some contexts, such as in Lisp programming, the term list may refer specifically to a linked list rather than an array. In class-based programming, lists are usually provided as instances of subclasses of a generic "list" class, and traversed via separate iterators.

Many programming languages provide support for list data types, and have special syntax and semantics for lists and list operations. A list can often be constructed by writing the items in sequence, separated by commas, semicolons, and/or spaces, within a pair of delimiters such as parentheses '()', brackets '[]', braces '{}', or angle brackets '<>'. Some languages may allow list types to be indexed or sliced like array types, in which case the data type is more accurately described as an array.

In type theory and functional programming, abstract lists are usually defined inductively by two operations: nil that yields the empty list, and cons, which adds an item at the beginning of a list.[1]

A stream is the potentially infinite analog of a list.[2]:?§3.5?

Operations

edit

Implementation of the list data structure may provide some of the following operations:

  • create
  • test for empty
  • add item to beginning or end
  • access the first or last item
  • access an item by index

Implementations

edit

Lists are typically implemented either as linked lists (either singly or doubly linked) or as arrays, usually variable length or dynamic arrays.

The standard way of implementing lists, originating with the programming language Lisp, is to have each element of the list contain both its value and a pointer indicating the location of the next element in the list. This results in either a linked list or a tree, depending on whether the list has nested sublists. Some older Lisp implementations (such as the Lisp implementation of the Symbolics 3600) also supported "compressed lists" (using CDR coding) which had a special internal representation (invisible to the user). Lists can be manipulated using iteration or recursion. The former is often preferred in imperative programming languages, while the latter is the norm in functional languages.

Lists can be implemented as self-balancing binary search trees holding index-value pairs, providing equal-time access to any element (e.g. all residing in the fringe, and internal nodes storing the right-most child's index, used to guide the search), taking the time logarithmic in the list's size, but as long as it doesn't change much will provide the illusion of random access and enable swap, prefix and append operations in logarithmic time as well.[3]

Programming language support

edit

Some languages do not offer a list data structure, but offer the use of associative arrays or some kind of table to emulate lists. For example, Lua provides tables. Although Lua stores lists that have numerical indices as arrays internally, they still appear as dictionaries.[4]

In Lisp, lists are the fundamental data type and can represent both program code and data. In most dialects, the list of the first three prime numbers could be written as (list 2 3 5). In several dialects of Lisp, including Scheme, a list is a collection of pairs, consisting of a value and a pointer to the next pair (or null value), making a singly linked list.[5]

Applications

edit

Unlike in an array, a list can expand and shrink.

In computing, lists are easier to implement than sets. A finite set in the mathematical sense can be realized as a list with additional restrictions; that is, duplicate elements are disallowed and order is irrelevant. Sorting the list speeds up determining if a given item is already in the set, but in order to ensure the order, it requires more time to add new entry to the list. In efficient implementations, however, sets are implemented using self-balancing binary search trees or hash tables, rather than a list.

Lists also form the basis for other abstract data types including the queue, the stack, and their variations.

Abstract definition

edit

The abstract list type L with elements of some type E (a monomorphic list) is defined by the following functions:

nil: () → L
cons: E × LL
first: LE
rest: LL

with the axioms

first (cons (e, l)) = e
rest (cons (e, l)) = l

for any element e and any list l. It is implicit that

cons (e, l) ≠ l
cons (e, l) ≠ e
cons (e1, l1) = cons (e2, l2) if e1 = e2 and l1 = l2

Note that first (nil ()) and rest (nil ()) are not defined.

These axioms are equivalent to those of the abstract stack data type.

In type theory, the above definition is more simply regarded as an inductive type defined in terms of constructors: nil and cons. In algebraic terms, this can be represented as the transformation 1 + E × LL. first and rest are then obtained by pattern matching on the cons constructor and separately handling the nil case.

The list monad

edit

The list type forms a monad with the following functions (using E* rather than L to represent monomorphic lists with elements of type E):

 
 

where append is defined as:

 

Alternatively, the monad may be defined in terms of operations return, fmap and join, with:

 
 

Note that fmap, join, append and bind are well-defined, since they're applied to progressively deeper arguments at each recursive call.

The list type is an additive monad, with nil as the monadic zero and append as monadic sum.

Lists form a monoid under the append operation. The identity element of the monoid is the empty list, nil. In fact, this is the free monoid over the set of list elements.

See also

edit
  • Array data type – Data type that represents an ordered collection of elements (values or variables)
  • Queue – Abstract data type
  • Set – Abstract data type for storing unique values
  • Stack – Abstract data type
  • Stream – Sequence of data items available over time

References

edit
  1. ^ Reingold, Edward; Nievergelt, Jurg; Narsingh, Deo (1977). Combinatorial Algorithms: Theory and Practice. Englewood Cliffs, New Jersey: Prentice Hall. pp. 38–41. ISBN 0-13-152447-X.
  2. ^ Abelson, Harold; Sussman, Gerald Jay (1996). Structure and Interpretation of Computer Programs. MIT Press.
  3. ^ Barnett, Granville; Del tonga, Luca (2008). "Data Structures and Algorithms" (PDF). mta.ca. Retrieved 12 November 2014.
  4. ^ Lerusalimschy, Roberto (December 2003). Programming in Lua (first edition) (First ed.). Lua.org. ISBN 8590379817. Retrieved 12 November 2014.
  5. ^ Steele, Guy (1990). Common Lisp (Second ed.). Digital Press. pp. 29–31. ISBN 1-55558-041-6.
吃什么瘦肚子 柠檬酸是什么 crc是什么职业 撒丫子是什么意思 放射治疗是什么意思
番茄是什么时候传入中国的 憩室炎吃什么药 老年斑是什么原因引起的 再生聚酯纤维是什么面料 补白蛋白吃什么食物最快最好
李白是什么 资产负债率高说明什么 hpv52型阳性是什么意思严重吗 身上经常痒是什么原因 什么来什么去
妈妈咪呀是什么意思 寸脉弱是什么原因 孕期脸上长痘痘是什么原因 不什么其什么的成语 poscer是什么牌子
单独玉米粉能做什么hcv8jop4ns6r.cn 祸水什么意思hcv8jop6ns9r.cn 银耳汤有什么功效hcv8jop1ns6r.cn 公分的单位是什么hcv9jop1ns9r.cn 支气管扩张是什么意思hcv8jop0ns2r.cn
marni是什么品牌hcv8jop3ns2r.cn 掉头发是什么原因引起的hcv9jop8ns0r.cn sheep什么意思jiuxinfghf.com 生日当天忌穿什么颜色hcv8jop8ns0r.cn 脖子为什么有颈纹hcv9jop5ns5r.cn
刑事拘留意味着什么hcv8jop8ns5r.cn 思想包袱是什么意思hcv9jop5ns1r.cn 红曲红是什么东西hcv9jop5ns9r.cn 血小板低会有什么症状hcv9jop7ns9r.cn 扁平足适合穿什么鞋hcv8jop3ns3r.cn
海的尽头是什么xianpinbao.com 鼻子流水是什么原因hcv8jop8ns7r.cn 什么的雪花hcv7jop6ns8r.cn 跖疣念什么字hcv8jop8ns5r.cn 如五行属什么hcv8jop3ns4r.cn
百度