韭菜吃多了有什么坏处| 尿隐血十1是什么意思| 便秘是什么症状| 氟哌酸又叫什么名字| 古代内衣叫什么| 狐臭用什么药| 红茶属于什么茶| 什么药可以降肌酐| 清鱼是什么鱼| 喜用神是什么意思| 格色是什么意思| 说话快的人什么性格| 坤字五行属什么| 便秘应该挂什么科室| 早孕试纸和验孕棒有什么区别| 孕妇不能吃什么| 古龙香水什么味道| 碘吃多了有什么危害| 三文鱼刺身是什么意思| 口干舌燥吃什么药| 什么而去的四字词语| 百香果什么味道| 什么是痛风| 纹眉需要注意什么| 江西特产有什么| 白敬亭父母是干什么的| 血虚是什么原因造成的| 肠炎能吃什么水果| 更年期有什么表现| 胖脸适合什么发型| 7月11号什么星座| 什么石头最值钱| 摔跤擦伤破皮擦什么药| 私奔是什么意思| 弯了是什么意思| 补充微量元素吃什么| 阳痿早泄是什么意思| 高血脂是什么意思| 龙涎是什么| 心季吃什么药| 血栓弹力图是查什么的| 中单是什么| 鸿五行属什么| 9月10日是什么节| 颈椎退变是什么意思| 球蛋白适合什么人打| 气郁症是什么症状| 卡西欧属于什么档次| 糖醇是什么意思| 泌乳素什么时候查最准确| 6月28日是什么星座| 脸上长肉疙瘩是什么原因| 脾胃虚弱吃什么好| 橄榄枝象征着什么| 月子里可以吃什么水果| 芈月和嬴政什么关系| 藕色是什么颜色| 世界上最软的东西是什么| 打喷嚏流清鼻涕属于什么感冒| 甜菊糖苷是什么| 出痧是什么意思| 2b是什么意思| 月经头疼是什么原因| 三项规定内容是什么| 旖旎风光是什么意思| 中考报名号是什么| 双腿酸软无力吃什么药| cordura是什么面料| 山药有什么营养| 烟酰胺是什么东西| 临幕是什么意思| 眼压高用什么药| 膜拜是什么意思| 慢性咽喉炎什么症状| 幻和是什么意思| 宽字五行属什么| 俗不可耐什么意思| 老鼠的克星是什么| 88属什么生肖| 姜汁可乐有什么功效与作用| 兰花用什么肥料最好| 牛仔布料是什么面料| 做背有什么好处及作用| 1450是什么意思| 晚上吃什么菜| 什么中药化结石最厉害| 头痛是什么病的前兆| adhd是什么意思| nilm是什么意思| 花木兰是什么剧种| 思维跳脱是什么意思| 如痴如醉是什么意思| 请多指教是什么意思| 痛风吃什么肉最好| 阿迪耐克为什么那么贵| 忍辱负重是什么意思| 岁岁年年是什么意思| 皮肤偏黄适合穿什么颜色的衣服| 出类拔萃是什么意思| 牛逼是什么| 卵巢疼是什么原因| 鱼子酱什么味道| 不食人间烟火是什么意思| 吃鸭蛋有什么好处和坏处| 吃多种维生素有什么好处和坏处| 气不够用是什么原因| 马卡龙是什么| 什么是回避型依恋人格| 胃不舒服能吃什么水果| 喝什么去湿气最好最快| 炼乳是什么东西| 西五行属什么| 流浓黄鼻涕是什么原因| 甘油三酯高吃什么能降下来| 伤口撒什么药粉好得快| 数据中心是什么| 立夏有什么习俗| 特需门诊和专家门诊有什么区别| 生肖龙和什么生肖最配| 女性失眠吃什么药最好| 吃什么保养子宫和卵巢| 亮晶晶的什么| bcc是什么意思| 伤食是什么意思| 生完孩子吃什么补身体| 因子是什么| 女生经常手淫有什么危害| 吃什么能降血压| 业力重是什么意思| pp材质和ppsu材质有什么区别| 尿检3个加号什么意思| 转氨酶高吃什么药好| 哺乳期可以吃什么消炎药| 牙膏什么牌子好| George是什么意思| 蜘蛛为什么不是昆虫| 衣柜放什么代替樟脑丸| 什么丝什么缕| 心脏造影是什么意思| 心律不齐吃什么药好| 普瑞巴林胶囊治什么病| 什么时候冬天| 生力军什么意思| 安全起见是什么意思| 一什么十什么的成语| 声带小结是什么意思| 湿厕纸是干什么用的| 阿迪达斯neo什么意思| 健身rm是什么意思| 给孩子测骨龄应该挂什么科| 等效球镜是什么意思| 打板是什么意思| 甘油三酯高是什么| 肌肉纤维化是什么意思| 麂皮是什么皮| 什么菜| 一切就绪是什么意思| 视网膜脱落有什么症状| 金兰之交是什么意思| 左上腹是什么器官| 积液是什么东西| 什么是人生格言| 三农是什么| 阴道炎用什么药最好| 额头出油多是什么原因| 周期性是什么意思| rsp是什么意思| 手掌小鱼际发红是什么原因| 什么情况会胎停| 爸爸是什么意思| 红楼梦结局是什么| 咳嗽吃什么食物好得快| 手脱皮吃什么维生素| 肛门里面痒是什么原因| 什么万| 雪藏是什么意思| 左束支传导阻滞是什么意思| 懒惰是什么意思| 孕早期适合吃什么水果| 知天命是什么年纪| 为什么喜欢秋天| 乳腺结节不能吃什么食物| 骨折补钙吃什么钙片好| 有时候会感到莫名的难过是什么歌| 五月二十九是什么日子| 什么感冒药效果最好| 乳腺增生结节吃什么药| 地龙是什么动物| o型血rh阳性是什么意思| dha中文叫什么| 旭五行属什么| 会车什么意思| 人脉是什么意思| 一个虫一个卑念什么| 掉头发多是什么原因| 风疟病是什么意思| 为国为民是什么生肖| 蓝莓有什么功效| 解酒的酶是什么酶| 壑是什么字| 霸王别姬是什么意思| 牙槽骨吸收是什么意思| 如果怀孕了会有什么预兆| 坐地能吸土是什么意思| 什么什么龙什么| 日有所思夜有所梦是什么意思| 皮肤过敏不能吃什么食物| 灰指甲长什么样子图片| 母亲节送妈妈什么礼物好| 痛风不能吃什么食物| 头疼头晕去医院挂什么科| 尿痛吃什么药效果最好| 眼肿是什么原因| 孩子上火吃什么药| 格力空调睡眠模式1234什么意思| 95年猪是什么命| 喝什么茶可以减肥| 水泡用什么药膏最有效| 尖锐湿疣是什么样的| app有什么用途| 李逵代表什么生肖| 蛟龙是什么| 回流什么意思| 橙子是什么季节的水果| 反酸是什么感觉| 燕窝什么季节吃最好| 粗人是什么意思| 五谷是什么| 乙状结肠ca是什么意思| 舌头变黑是什么原因| 珎是什么意思| 罹患率是什么意思| 细菌感染吃什么消炎药| 一个月一个非念什么| 梦到和别人打架是什么意思| 便秘吃什么益生菌| 喝什么茶降血糖| 生化是检查什么的| 三十如狼四十如虎什么意思| 持之以恒的恒是什么意思| 喝茉莉花茶有什么好处| 梦见棺材是什么意思| 抗凝血是什么意思| 家五行属什么| 为什么痣上面会长毛| 梦见好多黄鳝是什么意思| 耳朵听不清楚是什么原因| 心肌受损会出现什么症状| 西装裤配什么上衣| 蒲公英是什么样子| 吃了吐是什么原因| 吃什么菜| 什么叫压缩性骨折| 二月十三是什么星座| 好久不见是什么意思| 胃胀气是什么原因引起的| 射精太快吃什么药| 火眼是什么症状| 白喉采取什么隔离| 黄历今天是什么日子| 吃鸡什么意思| 有期徒刑是什么意思| 播客是什么意思| 塞上是什么意思| 百度Jump to content

鼓楼--江苏频道--人民网

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Dinsm8re (talk | contribs) at 22:58, 9 October 2024 (History: wording). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
百度 Z先生举了个他认为有点极端的例子,“圈里有个哥们身体不成了,每天都得输液,但他要在家里‘招待’朋友。

In computer science, array is a data type that represents a collection of elements (values or variables), each selected by one or more indices (identifying keys) that can be computed at run time during program execution. Such a collection is usually called an array variable or array value.[1] By analogy with the mathematical concepts vector and matrix, array types with one and two indices are often called vector type and matrix type, respectively. More generally, a multidimensional array type can be called a tensor type, by analogy with the physical concept, tensor.[2]

Language support for array types may include certain built-in array data types, some syntactic constructions (array type constructors) that the programmer may use to define such types and declare array variables, and special notation for indexing array elements.[1] For example, in the Pascal programming language, the declaration type MyTable = array [1..4,1..2] of integer, defines a new array data type called MyTable. The declaration var A: MyTable then defines a variable A of that type, which is an aggregate of eight elements, each being an integer variable identified by two indices. In the Pascal program, those elements are denoted A[1,1], A[1,2], A[2,1], …, A[4,2].[3] Special array types are often defined by the language's standard libraries.

Dynamic lists are also more common and easier to implement[dubiousdiscuss] than dynamic arrays. Array types are distinguished from record types mainly because they allow the element indices to be computed at run time, as in the Pascal assignment A[I,J] := A[N-I,2*J]. Among other things, this feature allows a single iterative statement to process arbitrarily many elements of an array variable.

In more theoretical contexts, especially in type theory and in the description of abstract algorithms, the terms "array" and "array type" sometimes refer to an abstract data type (ADT) also called abstract array or may refer to an associative array, a mathematical model with the basic operations and behavior of a typical array type in most languages – basically, a collection of elements that are selected by indices computed at run-time.

Depending on the language, array types may overlap (or be identified with) other data types that describe aggregates of values, such as lists and strings. Array types are often implemented by array data structures, but sometimes by other means, such as hash tables, linked lists, or search trees.

History

Heinz Rutishauser's programming language Superplan (1949–1951) included multi-dimensional arrays. However, although Rutishauser described how a compiler for his language should be built, did not implement one.

Assembly languages and low-level languages like BCPL[4] generally have no syntactic support for arrays.

Because of the importance of array structures for efficient computation, the earliest high-level programming languages, including FORTRAN (1957), COBOL (1960), and Algol 60 (1960), provided support for multi-dimensional arrays.

Abstract arrays

An array data structure can be mathematically modeled as an abstract data structure (an abstract array) with two operations

get(A, I): the data stored in the element of the array A whose indices are the integer tuple I.
set(A,I,V): the array that results by setting the value of that element to V.

These operations are required to satisfy the axioms[5]

get(set(A,I, V), I) = V
get(set(A,I, V), J) = get(A, J) if I ≠ J

for any array state A, any value V, and any tuples I, J for which the operations are defined.

The first axiom means that each element behaves like a variable. The second axiom means that elements with distinct indices behave as disjoint variables, so that storing a value in one element does not affect the value of any other element.

These axioms do not place any constraints on the set of valid index tuples I, therefore this abstract model can be used for triangular matrices and other oddly-shaped arrays.

Implementations

In order to effectively implement variables of such types as array structures (with indexing done by pointer arithmetic), many languages restrict the indices to integer data types[6][7] (or other types that can be interpreted as integers, such as bytes and enumerated types), and require that all elements have the same data type and storage size. Most of those languages also restrict each index to a finite interval of integers, that remains fixed throughout the lifetime of the array variable. In some compiled languages, in fact, the index ranges may have to be known at compile time.

On the other hand, some programming languages provide more liberal array types, that allow indexing by arbitrary values, such as floating-point numbers, strings, objects, references, etc.. Such index values cannot be restricted to an interval, much less a fixed interval. So, these languages usually allow arbitrary new elements to be created at any time. This choice precludes the implementation of array types as array data structures. That is, those languages use array-like syntax to implement a more general associative array semantics, and must therefore be implemented by a hash table or some other search data structure.

Language support

Multi-dimensional arrays

The number of indices needed to specify an element is called the dimension, dimensionality, or rank of the array type. (This nomenclature conflicts with the concept of dimension in linear algebra, which expresses the shape of a matrix. Thus, an array of numbers with 5 rows and 4 columns, hence 20 elements, is said to have dimension 2 in computing contexts, but represents a matrix that is said to be 4×5-dimensional. Also, the computer science meaning of "rank" conflicts with the notion of tensor rank, which is a generalization of the linear algebra concept of rank of a matrix.)

A two-dimensional array stored as a one-dimensional array of one-dimensional arrays (rows)
A two-dimensional array stored as a one-dimensional array of one-dimensional arrays (rows)

Many languages support only one-dimensional arrays. In those languages, a multi-dimensional array is typically represented by an Iliffe vector, a one-dimensional array of references to arrays of one dimension less. A two-dimensional array, in particular, would be implemented as a vector of pointers to its rows. Thus an element in row i and column j of an array A would be accessed by double indexing (A[i][j] in typical notation). This way of emulating multi-dimensional arrays allows the creation of jagged arrays, where each row may have a different size – or, in general, where the valid range of each index depends on the values of all preceding indices.

This representation for multi-dimensional arrays is quite prevalent in C and C++ software. However, C and C++ will use a linear indexing formula for multi-dimensional arrays that are declared with compile time constant size, e.g. by int A[10][20] or int A[m][n], instead of the traditional int **A.[8]

Indexing notation

Most programming languages that support arrays support the store and select operations, and have special syntax for indexing. Early languages used parentheses, e.g. A(i,j), as in FORTRAN; others choose square brackets, e.g. A[i,j] or A[i][j], as in Algol 60 and Pascal (to distinguish from the use of parentheses for function calls).

Index types

Array data types are most often implemented as array structures: with the indices restricted to integer (or totally ordered) values, index ranges fixed at array creation time, and multilinear element addressing. This was the case in most "third generation" languages, and is still the case of most systems programming languages such as Ada, C, and C++. In some languages, however, array data types have the semantics of associative arrays, with indices of arbitrary type and dynamic element creation. This is the case in some scripting languages such as Awk and Lua, and of some array types provided by standard C++ libraries.

Bounds checking

Some languages (like Pascal and Modula) perform bounds checking on every access, raising an exception or aborting the program when any index is out of its valid range. Compilers may allow these checks to be turned off to trade safety for speed. Other languages (like FORTRAN and C) trust the programmer and perform no checks. Good compilers may also analyze the program to determine the range of possible values that the index may have, and this analysis may lead to bounds-checking elimination.

Index origin

Some languages, such as C, provide only zero-based array types, for which the minimum valid value for any index is 0.[9] This choice is convenient for array implementation and address computations. With a language such as C, a pointer to the interior of any array can be defined that will symbolically act as a pseudo-array that accommodates negative indices. This works only because C does not check an index against bounds when used.

Other languages provide only one-based array types, where each index starts at 1; this is the traditional convention in mathematics for matrices and mathematical sequences. A few languages, such as Pascal and Lua, support n-based array types, whose minimum legal indices are chosen by the programmer. The relative merits of each choice have been the subject of heated debate. Zero-based indexing can avoid off-by-one or fencepost errors.[10]

Highest index

The relation between numbers appearing in an array declaration and the index of that array's last element also varies by language. In many languages (such as C), one should specify the number of elements contained in the array; whereas in others (such as Pascal and Visual Basic .NET) one should specify the numeric value of the index of the last element. Needless to say, this distinction is immaterial in languages where the indices start at 1, such as Lua.

Array algebra

Some programming languages support array programming, where operations and functions defined for certain data types are implicitly extended to arrays of elements of those types. Thus one can write A+B to add corresponding elements of two arrays A and B. Usually these languages provide both the element-by-element multiplication and the standard matrix product of linear algebra, and which of these is represented by the * operator varies by language.

Languages providing array programming capabilities have proliferated since the innovations in this area of APL. These are core capabilities of domain-specific languages such as GAUSS, IDL, Matlab, and Mathematica. They are a core facility in newer languages, such as Julia and recent versions of Fortran. These capabilities are also provided via standard extension libraries for other general purpose programming languages (such as the widely used NumPy library for Python).

String types and arrays

Many languages provide a built-in string data type, with specialized notation ("string literals") to build values of that type. In some languages (such as C), a string is just an array of characters, or is handled in much the same way. Other languages, like Pascal, may provide vastly different operations for strings and arrays.

Array index range queries

Some programming languages provide operations that return the size (number of elements) of a vector, or, more generally, range of each index of an array. In C and C++ arrays do not support the size function, so programmers often have to declare separate variable to hold the size, and pass it to procedures as a separate parameter.

Elements of a newly created array may have undefined values (as in C), or may be defined to have a specific "default" value such as 0 or a null pointer (as in Java).

In C++ a std::vector object supports the store, select, and append operations with the performance characteristics discussed above. Vectors can be queried for their size and can be resized. Slower operations like inserting an element in the middle are also supported.

Slicing

An array slicing operation takes a subset of the elements of an array-typed entity (value or variable) and then assembles them as another array-typed entity, possibly with other indices. If array types are implemented as array structures, many useful slicing operations (such as selecting a sub-array, swapping indices, or reversing the direction of the indices) can be performed very efficiently by manipulating the dope vector of the structure. The possible slicings depend on the implementation details: for example, FORTRAN allows slicing off one column of a matrix variable, but not a row, and treat it as a vector; whereas C allow slicing off a row from a matrix, but not a column.

On the other hand, other slicing operations are possible when array types are implemented in other ways.

Resizing

Some languages allow dynamic arrays (also called resizable, growable, or extensible): array variables whose index ranges may be expanded at any time after creation, without changing the values of its current elements.

For one-dimensional arrays, this facility may be provided as an operation "append(A,x)" that increases the size of the array A by one and then sets the value of the last element to x. Other array types (such as Pascal strings) provide a concatenation operator, which can be used together with slicing to achieve that effect and more. In some languages, assigning a value to an element of an array automatically extends the array, if necessary, to include that element. In other array types, a slice can be replaced by an array of different size, with subsequent elements being renumbered accordingly – as in Python's list assignment "A[5:5] = [10,20,30]", that inserts three new elements (10,20, and 30) before element "A[5]". Resizable arrays are conceptually similar to lists, and the two concepts are synonymous in some languages.

An extensible array can be implemented as a fixed-size array, with a counter that records how many elements are actually in use. The append operation merely increments the counter; until the whole array is used, when the append operation may be defined to fail. This is an implementation of a dynamic array with a fixed capacity, as in the string type of Pascal. Alternatively, the append operation may re-allocate the underlying array with a larger size, and copy the old elements to the new area.

See also

References

  1. ^ a b Robert W. Sebesta (2001) Concepts of Programming Languages. Addison-Wesley. 4th edition (1998), 5th edition (2001), ISBN 9780201385960
  2. ^ "Introduction to Tensors | TensorFlow Core". TensorFlow.
  3. ^ K. Jensen and Niklaus Wirth, PASCAL User Manual and Report. Springer. Paperback edition (2007) 184 pages, ISBN 978-3540069508
  4. ^ John Mitchell, Concepts of Programming Languages. Cambridge University Press.
  5. ^ Lukham, Suzuki (1979), "Verification of array, record, and pointer operations in Pascal". ACM Transactions on Programming Languages and Systems 1 (2), 226–244.
  6. ^ Deitel, Harvey M.; Deitel, Paul J. (2005). C# for Programmers. Prentice Hall Professional. p. 303. ISBN 978-0-13-246591-5. Retrieved 22 May 2024.
  7. ^ Friesen, Jeff (5 March 2014). Learn Java for Android Development: Java 8 and Android 5 Edition. Apress. p. 56. ISBN 978-1-4302-6455-2. Retrieved 22 May 2024.
  8. ^ Brian W. Kernighan and Dennis M. Ritchie (1988), The C programming Language. Prentice-Hall, p. 81.
  9. ^ Kernighan, Brian W.; Ritchie, Dennis M. (1988). The C programming language (2nd ed.). Englewood Cliffs, N.J: Prentice Hall. p. 24. ISBN 978-0-13-110370-2.
  10. ^ Edsger W. Dijkstra, "Why numbering should start at zero"
头发麻是什么原因 幽门螺杆菌是一种什么病 驿站是什么意思 荆芥俗名叫什么 什么可以去湿气
猫什么时候传入中国 合胞病毒是什么病毒 吃桂圆干有什么好处和坏处 抽血血液偏黑什么原因 来月经有异味什么原因
铁蛋白低吃什么可以补 就不告诉你就不告诉你是什么儿歌 蒲地蓝消炎片治什么病 1976年属什么生肖 一头雾水什么意思
冷笑是什么意思 百合为什么是苦的 诸葛亮为什么气死周瑜 菱形脸适合什么发型 尔加玉读什么
流汗有什么好处youbangsi.com 大小周是什么意思hcv8jop5ns3r.cn 螳螂吃什么hcv8jop3ns7r.cn 月子吃什么最下奶hcv9jop1ns0r.cn 子宫憩室有什么症状hcv8jop8ns9r.cn
金钱骨是什么部位hcv7jop6ns2r.cn 海鸥吃什么hcv8jop4ns9r.cn 66.66红包代表什么意思hcv9jop5ns8r.cn 野生铁皮石斛什么价bjhyzcsm.com 西瓜有什么好处creativexi.com
什么药补肾最好xscnpatent.com 打不死的小强什么意思hcv8jop9ns4r.cn 昵称什么意思hcv8jop7ns2r.cn 什么是酒糟鼻hcv7jop6ns2r.cn 汪峰是什么星座luyiluode.com
汗疱疹是什么原因引起hcv9jop2ns6r.cn oem贴牌是什么意思hcv8jop3ns4r.cn 神经衰弱吃什么药效果最好hcv9jop2ns1r.cn 什么是高hkuteam.com 黄帝是一个什么样的人mmeoe.com
百度