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 

 


Hivatalos, hogy jön a Haikyuu!! Gomisuteba no Kessen movie! Magyar nyelvû plakát, magyar feliratos elõzetes!    *****    Todoroki Shoto Fanfiction oldal, nézzetek be és olvassatok! Új Shoto nendoroid blog az oldalon!    *****    A Múzsa, egy gruppi élményei a színfalak mögött :)    *****    Madarak és fák napjára új mesével vár a Mesetár! Nézz be hozzánk!    *****    Rosta Iván diplomás asztrológus vagyok! Szívesen elkészítem a horoszkópodat, fordúlj hozzám bizalommal. Várom a hívásod!    *****    Dryvit, hõszigetelés! Vállaljuk családi házak, lakások, egyéb épületek szigetelését kedvezõ áron! Hívjon! 0630/583-3168    *****    Ha te is könyvkiadásban gondolkodsz, ajánlom figyelmedbe az postomat, amiben minden összegyûjtött információt megírtam.    *****    Nyereményjáték! Nyerd meg az éjszakai arckrémet! További információkért és játék szabályért kattints! Nyereményjáték!    *****    A legfrissebb hírek Super Mario világából, plusz információk, tippek-trükkök, végigjátszások!    *****    Ha hagyod, hogy magával ragadjon a Mario Golf miliõje, akkor egy egyedi és életre szóló játékélménnyel leszel gazdagabb!    *****    A horoszkóp a lélek tükre, nagyon fontos idõnként megtudni, mit rejteget. Keress meg és nézzünk bele együtt. Várlak!    *****    Dryvit, hõszigetelés! Vállaljuk családi házak, lakások, nyaralók és egyéb épületek homlokzati szigetelését!    *****    rose-harbor.hungarianforum.com - rose-harbor.hungarianforum.com - rose-harbor.hungarianforum.com    *****    Vérfarkasok, boszorkányok, alakváltók, démonok, bukott angyalok és emberek. A világ oly' színes, de vajon békés is?    *****    Az emberek vakok, kiváltképp akkor, ha olyasmivel találkoznak, amit kényelmesebb nem észrevenni... - HUNGARIANFORUM    *****    Valahol Delaware államban létezik egy város, ahol a természetfeletti lények otthonra lelhetnek... Közéjük tartozol?    *****    Minden mágia megköveteli a maga árát... Ez az ár pedig néha túlságosan is nagy, hogy megfizessük - FRPG    *****    Why do all the monsters come out at night? - FRPG - Why do all the monsters come out at night? - FRPG - Aktív közösség    *****    Az oldal egy évvel ezelõtt költözött új otthonába, azóta pedig az élet csak pörög és pörög! - AKTÍV FÓRUMOS SZEREPJÁTÉK    *****    Vajon milyen lehet egy rejtélyekkel teli kisváros polgármesterének lenni? És mi történik, ha a bizalmasod árul el?