Raised This Month: $51 Target: $400
 12% 

Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]


Post New Thread Reply   
 
Thread Tools Display Modes
Chief149
Member
Join Date: Sep 2010
Old 06-09-2016 , 14:57   Re: Dynamic Objects and Properties - v.0.0.15 - [2016.06.08]
Reply With Quote #71

Now let's say I call something like:

myclass.SetString("SomeString", "", 256);

Technically I am providing a string of length 0, but am specifying a length of 256. Does this mean that I can set strings in the future of up to 256 characters long?
Chief149 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 06-09-2016 , 17:43   Re: Dynamic Objects and Properties - v.0.0.15 - [2016.06.08]
Reply With Quote #72

Correct.

Edit: ill explain memory allocation.

So we have arraylist[blocksize] to store data.

Lets represent this like: [cell1][cell2][cell3][...]

Say we set int 66 as the first member.

[Type_Int][66]

We have filled the first two blocks in index 0. A trie stores membername to offset 0.

Say we set a float next.

[Type_Int][66][Type_Float][66.66]

The next two blocks are filled and the offset is 2.

Say we set string "" for 8 length.

[Type_Int][66][Type_Float][66.66][Type_String][8][0,0,0,0][0,0,0,0].

Dynamic does store 4 chars per cell and you can see how the length is allocated.

Once blocksize is reached, dynamic creates a new index.

No memory if left unused as members are set.

Offsets always point to a cell that holds a type.

Types are stored to support type conversion.

GetString of the int we set would give us "66".
__________________

Last edited by Neuro Toxin; 06-09-2016 at 18:06.
Neuro Toxin is offline
Chief149
Member
Join Date: Sep 2010
Old 06-09-2016 , 20:29   Re: Dynamic Objects and Properties - v.0.0.15 - [2016.06.08]
Reply With Quote #73

Oh nice. Now I can precisely calculate the blocksize for my objects! Every class member requires 2 cells. Strings require 2 cells like any other class member, plus maxlength/4 cells.

I've been looking more and more at your code. I wish I had thought of something like this much sooner!

It's nice being able to create as many of any type of custom object without being bound to arrays. And it's nice being able to save loads of memory with dynamic sizing, versus my idea of just inheriting an ArrayList or a Trie.
Chief149 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 06-11-2016 , 19:11   Re: Dynamic Objects and Properties - v.0.0.15 - [2016.06.08]
Reply With Quote #74

Quote:
Originally Posted by Chief149 View Post
Oh nice. Now I can precisely calculate the blocksize for my objects! Every class member requires 2 cells. Strings require 2 cells like any other class member, plus maxlength/4 cells.
Correct. Dont forget vectors: 4 cells (type+(3×float)).

Quote:
Originally Posted by Chief149 View Post
I've been looking more and more at your code. I wish I had thought of something like this much sooner!
This code / concept took some time. Thanks for the positive words.

Quote:
Originally Posted by Chief149 View Post
It's nice being able to create as many of any type of custom object without being bound to arrays. And it's nice being able to save loads of memory with dynamic sizing, versus my idea of just inheriting an ArrayList or a Trie.
Part of my brief in concept stage was unlimited dynamic members.

There are massive advantages over using straight array indicies and the main being memory waistage as soon as you throw strings in.

Also note how members are not restricted with string size as blocksize is avoided.

Inheriting a trie is the best datastorage method that avoids sized type arrays defined as globals. Dynamic does this but doesn't store the members data in a trie as part of the brief was full type support for type conversion.
__________________
Neuro Toxin is offline
Chief149
Member
Join Date: Sep 2010
Old 06-16-2016 , 16:57   Re: Dynamic Objects and Properties - v.0.0.15 - [2016.06.08]
Reply With Quote #75

Honestly this should be a sticky! Or maybe even part of SM's included libraries. This is probably one of the most essential things for the transitional syntax of sourcemod to be uploaded.
Chief149 is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 06-19-2016 , 16:17   Re: Dynamic Objects and Properties - v.0.0.15 - [2016.06.08]
Reply With Quote #76

Quote:
Originally Posted by Chief149 View Post
Honestly this should be a sticky! Or maybe even part of SM's included libraries. This is probably one of the most essential things for the transitional syntax of sourcemod to be uploaded.
i 100% agree, we don't need a plugin as a dependency for dynamic objects/classes that every modern object oriented language has
again; thanks neurotoxin!
__________________
retired
shavit is offline
Chief149
Member
Join Date: Sep 2010
Old 06-20-2016 , 11:38   Re: Dynamic Objects and Properties - v.0.0.15 - [2016.06.08]
Reply With Quote #77

Quote:
Originally Posted by shavit View Post
i 100% agree, we don't need a plugin as a dependency for dynamic objects/classes that every modern object oriented language has
again; thanks neurotoxin!
Well, one thing you should note is that SourcePawn is NOT a modern day object oriented language. It is a modern-day procedural language just like C (not C++).

It just happens that we've figured out how to do something that Sourcepawn was never designed to do (and wouldn't have been possible without method mapping).
Chief149 is offline
dubbeh
Senior Member
Join Date: Jul 2007
Old 06-21-2016 , 08:58   Re: Dynamic Objects and Properties - v.0.0.15 - [2016.06.08]
Reply With Quote #78

Quote:
Originally Posted by Chief149 View Post
Honestly this should be a sticky! Or maybe even part of SM's included libraries. This is probably one of the most essential things for the transitional syntax of sourcemod to be uploaded.
Couldn't agree more, this is a great extension. Thanks Neuro.
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome
dubbeh is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 06-28-2016 , 19:37   Re: Dynamic Objects and Properties - v.0.0.15 - [2016.06.08]
Reply With Quote #79

I've created collections.

Here is an example.
__________________
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-14-2016 , 03:11   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #80

Dynamic has been updated to version 0.0.16

- Fixed valuelength param for ReadConfig/KeyValues
- Long values now store as strings for ReadConfig/KeyValues
__________________
Neuro Toxin is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode