Az Ego kicsiny világa ;-)
Menü
 
Bejelentkezés
Felhasználónév:

Jelszó:
SúgóSúgó
Elfelejtettem a jelszót
 
Olvasgatom...
 
 
társalgó
Név:

Üzenet:
:)) :) :@ :? :(( :o :D ;) 8o 8p 8) 8| :( :'( ;D :$
 
Site Meter


moon phases
~ Computer related
~ Computer related : The structure of a dynamic array

The structure of a dynamic array

Ch. Oe.  2007.05.13. 07:25

If you want to access an array you need to know the number of the field

1. WHAT IS AN ARRAY?
An array is a variable type. It intends to give access on a large number of variables. An array like a street of houses, each with a house-number and a certain houses. The house number is the number you access a array field with and the house and it's content represents the data in the array field.  
To declare an array you need to tell the compiler how much variables the array should have and of which type they should be:  
  ArrayName : array[OrdinalStartValue..OrdinalEndValue] of VariabelType;  
If you want to access an array you need to know the number of the field:  
  VariableInField := ArrayName[NumberOfField];  
An array can be have more dimensions. An 2-D array would be like a number of streets all named with numbers 1,2,3... and each with houses. To get to a house you need street number and house number. The declaration is very similar:  
  ArrayName : array[FirstDimensionStart..FirstDimensionEnd] of array[SecondDimensionStart..SecondDimensionEnd] of VariableType  
or  
  ArrayName : array[1stDStart..1stDEnd, 2ndDStart..2ndDEnd] of VariableType
2. WHAT IS THE PROBLEM?
Arrays are very big that's the problem. An array is static, i.d. it exists from the construction of the object(see Object Oriented Programming) or starting of the program to it's destruction or ending, which brings the problem that the writer of the program has to know in the moment of the construction how large the array has to be and has no chance to resize the array. What this means is very easy, if you don't know how large the array will be and you cannot resize it, you have to choose the biggest size that you could imagine to occur. You can easily think of the memory you'll waste, when creating such a big array, that in most times will be empty!!  
When the variables are small then this doesn't matter you might say, but think of an array of objects, each which ten, twenty variables, methods..., mh,..., uh..., that's not right I have to admit. Object is a bad example, because when you create an array of objects, it is made up out of Pointers which point at the object, so you can leave the objects uncreated and create them on demand. Okay, but I know that you use dynamic arrays also for objects, I gonna ask about this. So consider strings, 255 byte in size... :). Poor reasoning I have to admit, so althought I cannot say exactely why I can say how...
3. HOW IS THE PROBLEM SOLVED?
The Problem is solved by creating an array of Pointers on the elements and creating an Pointer that points on this array:  
type
  TDataStore = String;
  PDataStore = ^TDataStore;
  TDataStoreList = array[StartValue..EndValue] of PDataStore;
  PDataStoreList = ^TDataStoreList;
 
In the beginning when the list should be empty you let the fDataStoreList (a variable of type PDataStoreList(see Naming and Formating Convention)) point on nothing and set up an counter for the elements with starting value 0, named fCount. When you want to add an item you have to:
1. Create an memory area for fCount + 1 pointers on TDataStore.
2. Move all entries from the former memory area the Pointer on the list was pointing to the new list.
3. Point on this area with your pointer on the list.
4. Free the old memory area.
5. Point on the item, which should be added, with a pointer, which is set up as entry No. fCount +1 of the list.(This means the pointer is added to the memory field).
6. Increase fCount by 1.
 
Dynamic Arrays:
Ch.Oe.

 
Hasznos Linkek
 
Melegedj a tüznél
 
Movie Linkek:
 
Érdekes honlapok:
 
Homepages:
 
Zene, klippek:
 

NOTE:

All Pictures belong to the respected artists and movie companies. No money is made in the usage or making of this site. Please support the artists by buying their movies. I do not upload any of these pictures and images. None of these pictures and photos are mine. If Your picture, image or photo is on here and you want it off, email me and I will take it off right away: 

  zen.titusz@gmail.com 

 


Elindult a Játék határok nélkül rajongói oldal! Ha te is szeretted a '90-es évek népszerû mûsorát, nézz be ide!    *****    Megjelent a Nintendo Switch 2 és a Mario Kart World! Ennek örömére megújítottam a Hungarian Super Mario Fan Club oldalt.    *****    Homlokzati hõszigetelés! Vállaljuk családi házak, nyaralók és egyéb épületek homlokzati szigetelését! 0630/583-3168    *****    A PlayStation 3 átmeneti fiaskója után a PlayStation 4 ismét sikersztori volt. Ha kíváncsi vagy a történetére, katt ide!    *****    A Bakuten!! az egyik leginkább alulértékelt sportanime. Egyedi, mégis csodálatos alkotásról van szó. Itt olvashatsz róla    *****    A PlayStation 3-ra jelentõsen felborultak az erõviszonyok a konzolpiacon. Ha érdekel a PS3 története, akkor kattints ide    *****    Új mese a Mesetárban! Téged is vár, gyere bátran! Mese, mese, meskete - ha nem hiszed, nézz bele!    *****    Az Anya, ha mûvész - Beszélgetés Hernádi Judittal és lányával, Tarján Zsófival - 2025.05.08-án 18:00 -Corinthia Budapest    *****    ✨ Egy receptes gyûjtemény, ahol a lélek is helyet kapott – ismerd meg a „Megóvlak” címû írást!    *****    Hímes tojás, nyuszipár, téged vár a Mesetár! Kukkants be hozzánk!    *****    Dryvit, hõszigetelés! Vállaljuk családi házak, nyaralók és egyéb épületek homlokzati szigetelését! 0630/583-3168    *****    Nagyon ütõs volt a Nintendo Switch 2 Direct! Elemzést a látottakról pedig itt olvashatsz!    *****    Elkészítem születési horoszkópod és ajándék 3 éves elõrejelzésed. Utána szóban minden kérdésedet megbeszéljük! Kattints    *****    Könyves oldal - egy jó könyv, elrepít bárhová - Könyves oldal    *****    20 éve jelent meg a Nintendo DS! Emlékezzünk meg ról, hisz olyan sok szép perccel ajándékozott meg minket a játékaival!    *****    Ha érdekelnek az animék,mangák,videojátékok, japán és holland nyelv és kultúra, akkor látogass el a személyes oldalamra.    *****    Dryvit, hõszigetelés! Vállaljuk családi házak, nyaralók és egyéb épületek homlokzati szigetelését! 0630/583-3168 Hívjon!    *****    Könyves oldal - Ágica Könyvtára - ahol megnézheted milyen könyveim vannak, miket olvasok, mik a terveim...    *****    Megtörtént Bûnügyekkel foglalkozó oldal - magyar és külföldi esetek.    *****    Why do all the monsters come out at night? - Rose Harbor, a város, ahol nem a természetfeletti a legfõbb titok - FRPG