Dynamic array and its features

Date:

2019-07-24 22:20:17

Views:

768

Rating:

1Like 0Dislike

Share:

Table of contents:

The Array in General case is called an ordered set of elements, each of which has a certain (the same) type. Arrays can be static or dynamic. The length of the first set in the programming phase, i.e. before the start of the program, the second – progress.
For a static array in the description must be defined the number of elements, which during operation of the program cannot be changed (increase or decrease). When you run a program that uses a static array for execution in RAM releases a certain amount of bytes to store its elements. This amount of memory will be assigned to the programme as long as she doesn't finish its work. Even if this memory is not used, no other code can't access it.
The Pascal programming Language can work only with static arrays. So, if you want to work with variable-length sequence, it is possible to describe the structure, for example, of a hundred items, and use at different stages a different number of elements not exceeding the number 100. And this, of course, unwise.
This problem does not exist in the integrated development environment Delphi. The dynamic array allows the description does not specify the number of elements, and to identify it during the execution of a program. A dynamic array can be described in the section Var in the following way:
Var Massive:array of integer

 delphi dynamic array

Thus, the structure indicated by the identifier of the Massive, is a linear integer sequence is unknown (yet!) length. To specify the size, the program must use the SetLength procedure, for example, SetLength(Massive,9). Dynamic array Massive will gain a dimension equal to the number 9. Now determined that in the sequence there are nine elements of an integer numbered from zero. Such features a dynamic array. Delphi has a procedure for releasing the memory from the set of numbers, when the need for storage has disappeared. This procedure is Finalize, in our case it will be applied as follows: Finalize(Massive).

dynamic array

Similarly, you can describe and apply multidimensional dynamic arrays in Delphi. For example, two-dimensional dynamic structure will be described as follows:
Var Massive:array of array of integer
If necessary, the columns of the matrix can be of different lengths. It also specifies a procedure SetLength.

dynamic array delphi

Often, especially in large and complex programs, some data structures are used from time to time or only at the beginning/end of the program. It would be very wasteful to keep the place in RAM “reserve”. Dynamic array – one of the ways the rational allocation of computing system resources. Although it has some drawbacks. First, it is not always convenient numbering of the elements from scratch. Second, the programmer need constantly to understand in every point of code, what is the status of the dynamic array. But its advantages make funny all these difficulties. In particular, if you want to transfer from the routine data of a large volume, without a dynamic way of presenting is not enough.


Article in other languages:

AR: https://tostpost.com/ar/computers/18583-dynamic-array-and-its-features.html

BE: https://tostpost.com/be/kamputary/35517-dynam-chny-mas-yago-asabl-vasc.html

DE: https://tostpost.com/de/computer/35163-dynamische-array-und-seine-eigenschaften.html

ES: https://tostpost.com/es/equipos/35025-la-matriz-din-mica-y-sus-caracter-sticas.html

HI: https://tostpost.com/hi/computers/20246-dynamic-array-and-its-features.html

JA: https://tostpost.com/ja/computers/18231-dynamic-array-and-its-features.html

KK: https://tostpost.com/kk/komp-yuterler/35810-dinamikaly-massiv-zh-ne-ony-erekshel-kter.html

PL: https://tostpost.com/pl/komputery/36959-dynamiczny-model-i-jego-cechy.html

PT: https://tostpost.com/pt/computadores/36747-um-array-din-mico-e-suas-caracter-sticas.html

TR: https://tostpost.com/tr/bilgisayarlar/32248-dinamik-bir-dizi-ve-zellikleri.html

UK: https://tostpost.com/uk/komp-yuteri/36070-dinam-chniy-masiv-yogo-osoblivost.html

ZH: https://tostpost.com/zh/computers/7796-dynamic-array-and-its-features.html






Alin Trodden - author of the article, editor
"Hi, I'm Alin Trodden. I write texts, read books, and look for impressions. And I'm not bad at telling you about it. I am always happy to participate in interesting projects."

Comments (0)

This article has no comment, be the first!

Add comment

Related News

What is the promo code in games?

What is the promo code in games?

How often in life there are times when you really want to get a particular product, but you think it is too expensive. And you refuse the idea, but hope to purchase the desired things always remains. Do you think that someday amas...

Èterievyj crown. How to get èterievyj crown in

Èterievyj crown. How to get èterievyj crown in "Skyrim"

Èterievyj crown – an ancient dwarven artifact, to which it is possible for a quest “Lost in the centuries”. On how to create this magical item and what benefits it provides, you'll see in this review.How to get t...

What you need to know about the console commands in CS: GO for sight

What you need to know about the console commands in CS: GO for sight

I guess every gamer has ever played in a game like Counter-Strike, so almost everyone knows that special AWP rifle no sight, making shooting from the hip gives a lot of inconvenience. Not everybody likes the standard sight for eac...

Slots - what is it?

Slots - what is it?

Computer components (RAM, sound card, video card, etc.) are connected via special interfaces – slots. This connectors to extend the capabilities of the PC. They can also be called cards or adapters. it's the RAM slots?As you...

How to run Android on your computer. Install Android on computer

How to run Android on your computer. Install Android on computer

it's No secret that for a long time, the Android system is treated with suspicion, and many fans of "Apple devices" even pretend it doesn't exist. But now more and more people, sated notorious fruit, began to pay attenti...

How to take over in Instagram and become popular?

How to take over in Instagram and become popular?

Flash mobs have always been popular not only in real life but also online. Often different races found in social networking sites. Their essence is to gather around a single topic, a huge number of people who should have certain c...