linked lists / array lists

forum.td.development (2005-2010)
NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

linked lists / array lists

Post by NewsgroupServer » 07 Oct 2009, 16:43

 Posted by:  Marco Westermann 

Hi,

from time to time I could need a list like LinkedList in Java (linked
list or array list) where I can add instances of our classes, for
example to build a list of customer. Is there a possibility to use such
a list, or are there any ready to use solutions for this problem
already? Thanks for any advice

Marco

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

linked lists / array lists

Post by NewsgroupServer » 08 Oct 2009, 14:40

 Posted by:  Tobias Jäkel 

I think there is no build in list in centura.

We created one on our own.

Tobias

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

linked lists / array lists

Post by NewsgroupServer » 08 Oct 2009, 16:08

 Posted by:  Jim McNamara 

Do you mean an array of a functional class?

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

linked lists / array lists

Post by NewsgroupServer » 09 Oct 2009, 09:11

 Posted by:  Marco Westermann 

Hi,

I know that there is no build in one. But how did you wrote your own
one. I didn't manage it, that the function MyLinkedList.add takes UDVs
of every Class. In my opinion the problem is, that there is no TopLevel
class every other class is derived from, like the class Object in Java.
Or do you have a class all other classes derives from?

Thanks, Marco

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

linked lists / array lists

Post by NewsgroupServer » 09 Oct 2009, 09:16

 Posted by:  Marco Westermann 


not only an array of one functional class. I mean a class that builds an
array of functional classes inside. But as flexible as I can build an
array of functional classes of every type. One problem I need such a
class is, that a function cannot return an array of a functional class.
(I know I could use a receive var, but even this is not as flexible
cause I can only use one type of functional class to fill that array)

best regards,
Marco

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

linked lists / array lists

Post by NewsgroupServer » 09 Oct 2009, 10:18

 Posted by:  Tobias Jäkel 

see the sample attached.

you can add every object to fcObjectCollection that is derived from fcObject
and you can add every objectwithid to fcObjectWithIDCollection that is
derived from fcObjectWithId.

Unfurtunately this version is very slow when getting an Item at a specific
position. (e.g. Object at the Index 30000 in a List of 50000 Objects).
May you find a possibility to improve this.

HTH Tobias

Attachment: list_classes.apl

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

linked lists / array lists

Post by NewsgroupServer » 09 Oct 2009, 14:59

 Posted by:  Jim McNamara 

A function can return a class array, and all classes that are passed as
parameters are passed by reference, so you have 2 methods to return the
array. You do, however, need to know what type of array is being passed.

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

linked lists / array lists

Post by NewsgroupServer » 09 Oct 2009, 16:49

 Posted by:  Krzysztof Dorko 

It is not true that you can use only one class in array.
You can create base class (call it i.e. Object like in .NET or Gupta
Automation) and make others derived from it.
Create an array of your base class and you will be able to collect all
types you want to and pass this array as a parameter and so on.
Whenever you will need to access certain properties you have to cast array
element to specific type and then you have an access to all methods an
properties of this type (class)
hth
Kris

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

linked lists / array lists

Post by NewsgroupServer » 25 May 2010, 09:15

 Posted by:  Marco Westermann 

Hi Kris,

thanks for your answer. And how can I cast an array element of a base
type back to the specific type?

lets assume, I have an array of class CObject. Now I push instances of
CSpecific to this array. Later I pass the array as parameter to another
function. How can I cast the elements back to type CSpecific?

Thanks Marco

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

linked lists / array lists

Post by NewsgroupServer » 26 May 2010, 23:41

 Posted by:  Stefan Beltrame 

Hi Marco

You can write a function like this:

Function CastAsCSpecific
Returns:
CSpecific:
Parameters
CSpecific: obj
Actions
Return obj

Now you are able to call
Set specific = CastAsCSpecific(object)

Regards

Stefan

Return to “td.development”

Who is online

Users browsing this forum: Ccbot [Crawler] and 0 guests