logo hardware to software Hardware To Software

Donate with Paypal

Theory, hardware, software and code

Archive for the ‘dynamic array’ tag

TList. To improve array management

Form-Employers

Form Employers

In previous two articles we talked about array management: copy by value and copy by pointer methods have been exposed to achieve same results but in different ways.
The former being direct and simply, the latter more powerful but danger (because of risks related to pointers).

If you get familiar with pointers you can understand their usefulness, so that they become sometimes necessary to ease some tasks; but we know their dangerousness!
Nothing stops us from building some construct, or data type thanks to which we can use pointers with a major security degree.

That’s probably what people who writes TList types (for every programming language) thinks.
This is because the list is a so powerful and useful and commonly used data structure written for homogeneous elements.
Well… homogeneous! This surely recalls an array. And that’s true!


Read the rest of this entry »

Written by admin

December 28th, 2011 at 12:24 pm

Array management by pointer

Form-Employers

Form Employers

In previous article Array management by value we talked about one way to grant to us access to array’s items: we used a by value approach, in the sense we surely took copy of items values by dereferencing a pointer to record we defined at the top of code.
Our intention was to emphasize that a copy by value can even be made with the help of a pointer.
Pointers in that context could represent an alternative way to archive or reach the documents: instead of alphabetically (array[index]), by coordinates (for example, just like in battleship).

 

Result is essentially the same:


  • we compile an original document and copy it to our file in archive;
  • we fetch documents, then copy info through pointers, manipulate them.

In other words, we prepare a new record with all data, then we store these values into an array of records; so we pass values.
On the other side we create locally a new record, where to host all fetched data from array, with pointer’s dereference. Read the rest of this entry »

Written by admin

December 21st, 2011 at 8:22 pm