SRL Archive - Development

The LibArrays for Simba.


CynicRus

2012-12-28 02:16:28

Hey. I Appearing idea to implement within the library(plugin) or an unit all the basic operations with arrays such as append,remove,remove duplicates, trim left, trim right,sort,intersection, difference and many other for Simba. I evolved these features, but mostly for myself. In your opinion, is it worth it to Simba? Or not worth wasting time on the transformation of its development in the plugin, because it is not necessary?

Update:

Unit prototype has been finished now. You may look at that here: http://paste.villavu.com/show/3773/

It remains to write a wrapper for PS and Lape and and it can be used from Simba:) The code has been tested and can be used in other projects in the Lazarus. (this version of the code does not contain the implementation of the function Swap for x64 plafrom. Anti-leech, lol):) I plan to write a wrapper in the next few days when I'll have time.

PS: Or someone can help me with writing wrappers. Immediately answer the question why I used Borland style to write code. I did this not to write different implementations of an algorithm for the different interpreters.

riwu

2012-12-28 02:33:00

Will they support all data types?

I think it's definitely worth adding them :)

My comments on the functions named above:

//Append
SetLength(a, 1);
a[High(a)]:= x;

//Remove
for i:=0 to High(a) do
if a[i] = x then
begin
DeleteValueIn{whatever}(x, i);
Break;
end;

//Remove duplicates
ClearDoubleTPA();
ClearSameIntegers();

//trim left/right
{possible to introduce slicing operations to Simba?}

//sort
{an universal sort function for all types/orders?}

//intersection/difference
{if only Pascal supports mathematical operations on sets...}

Le Jingle

2012-12-28 02:33:00

If it provides more options within simba for a user to interact with, I'd say yes worth it.

This comes from little idea - I imagine you mean we could have more features; I don't know if development wise, this may or may not be unnecessary?

CynicRus

2012-12-28 02:40:37

From: riwu
Will they support all data types?

I think it's definitely worth adding them :)

My comments on the functions named above:

//Append
SetLength(a, 1);
a[High(a)]:= x;

//Remove
for i:=0 to High(a) do
if a[i] = x then
begin
DeleteValueIn{whatever}(x, i);
Break;
end;

//Remove duplicates
ClearDoubleTPA();
ClearSameIntegers();

//trim left/right
{possible to introduce slicing operations to Simba?}

//sort
{an universal sort function for all types/orders?}

//intersection/difference
{if only Pascal supports mathematical operations on sets...}


Yes, it is designed for all types of arrays to Simba. With the exception perhaps TMufasaBitmap and DTM.

PS: Riwu, by Append I mean not only the addition of an item, but also the addition of an array in an array:)

riwu

2012-12-28 02:44:04

From: CynicRus
Yes, it is designed for all types of arrays to Simba. With the exception perhaps TMufasaBitmap and DTM.

That's great then! What language will you be writing this in?

CynicRus

2012-12-28 03:12:05

From: riwu
That's great then! What language will you be writing this in?

I chose Lazarus + FPC.

Le Jingle

2012-12-28 03:16:34

D: Why people vote no? Curious to why that is, perhaps explanation could help teach me/others a thing or two!

Dgby714

2012-12-28 04:16:20

I think you should make it, but build it into Simba so you can take advantage of magic functions.

Look at how we did WriteLn in PS. (Will take any type!)

We already have Swap, we need Append, Remove, and Insert.

CynicRus

2012-12-28 04:44:46

So, ok. I saw WriteLn and ToStr implementation on the Simba sources. But how can I use that from the plugin?

Wizzup?

2012-12-28 07:19:30

From: CynicRus
So, ok. I saw WriteLn and ToStr implementation on the Simba sources. But how can I use that from the plugin?


Don't make it a plugin? :)

CynicRus

2012-12-28 07:33:52

Yeah, I do it as a unit.:)

CynicRus

2012-12-29 02:11:25

Well, 75 percent of the work done. In the next few days I will finish it and lay out the code.:)

Le Jingle

2012-12-29 02:14:28

From: CynicRus
Well, 75 percent of the work done. In the next few days I will finish it and lay out the code.:)


Very cool & very much thanks! Cannot wait to try out

CynicRus

2013-01-02 04:16:45

Unit prototype has been finished now. You may look at that here: http://paste.villavu.com/show/3773/

It remains to write a wrapper for PS and Lape and and it can be used from Simba:) The code has been tested and can be used in other projects in the Lazarus. (this version of the code does not contain the implementation of the function Swap for x64 plafrom. Anti-leech, lol):) I plan to write a wrapper in the next few days when I'll have time.

ps: Or someone can help me with writing wrappers. Immediately answer the question why I used Borland style to write code. I did this not to write different implementations of an algorithm for the different interpreters.

nielsie95

2013-01-02 06:23:36

You shouldn't use move() on strings and variants as it will mess up the reference counts. CompareMem might also give unexpected results for strings/variants. And what about TPointArray/T2DPointArray?

Perhaps it's better to generate these functions (create a simple script which outputs the functions) or use FPC macros. Also, for Lape, I'll be adding a general Copy/Insert/Delete.

Other than that, this will be pretty useful! :)

CynicRus

2013-01-03 05:33:04

Nielsie95, thanks for you feedback. At the moment support for TPointArray is fully immplemented. Support multidimensional arrays will appear later. Thanks for the criticism of code, I'll certainly take it into consideration. At this point, I decide the problem of writing wrappers for Simba to the module.