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 

 


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    *****    A boroszkányok gyorsan megtanulják... Minden mágia megköveteli a maga árát. De vajon mekkora lehet ez az ár? - FRPG    *****    Alkosd meg a saját karaktered, és irányítsd a sorsát! Vajon képes lenne túlélni egy ilyen titkokkal teli helyen? - FRPG    *****    Mindig tudnod kell, melyik kikötõ felé tartasz. - ROSE HARBOR, a mi városunk - FRPG    *****    Akad mindannyijukban valami közös, valami ide vezette õket, a delaware-i aprócska kikötõvárosba... - FRPG    *****    boroszkány, vérfarkas, alakváltó, démon és angyal... szavak, amik mind jelentenek valamit - csatlakozz közénk - FRPG    *****    Why do all the monsters come out at night? - Rose Harbor, a város, ahol nem a természetfeletti a legfõbb titok - FRPG    *****    why do all monsters come out at night - FRPG - Csatlakozz közénk! - Írj, és éld át a kalandokat!    *****    CRIMECASESNIGHT - Igazi Bûntényekkel foglalkozó oldal    *****    Figyelem, figyelem! A második vágányra karácsonyi mese érkezett! Mesés karácsonyt kíván mindenkinek: a Mesetáros    *****    10 éves a Haikyuu!! Ennek alkalmából részletes elemzést olvashatsz az anime elsõ évadáról az Anime Odyssey blogban!    *****    Ismerd meg az F-Zero sorozatot, a Nintendo legdinamikusabb versenyjáték-szériáját! Folyamatosan bõvülõ tartalom.    *****    Advent a Mesetárban! Téli és karácsonyi mesék és színezõk várnak! Nézzetek be hozzánk!    *****    Nagyon pontos és részletes születési horoszkóp, valamint 3 év ajándék elõrejelzés, diplomás asztrológustól. Kattints!!!!    *****    A horoszkóp a lélek tükre,egyszer mindenkinek érdemes belenézni.Keress meg és én segítek értelmezni a csillagok állását!    *****    HAMAROSAN ÚJRA ITT A KARÁCSONY! HA SZERETNÉL KARÁCSONYI HANGULATBA KEVEREDNI, AKKOR KATT IDE: KARACSONY.GPORTAL.HU