Raised This Month: $ Target: $400
 0% 

Module: Vdf (key/value trees) - 1.07


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zenith77
Veteran Member
Join Date: Aug 2005
Old 02-24-2007 , 12:46   Re: Module: Vdf trees
Reply With Quote #1

Already have some requests, as I plan on using this module in two of my major projects.
I would like these two natives:

Code:
vdf_is_first_node(); vdf_is_last_node();

or perhaps collapse them into one native:

Code:
vdf_is_node_number(myNode, 1); vdf_is_node_number(myNode, vdf_num_nodes(myParentNode));

The latter one would require an additional native though, 'vdf_num_nodes()', which as you can tell returns the number of nodes in the current node.

Also, you should put everything in one big .zip file ^^..
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred

Last edited by Zenith77; 02-24-2007 at 13:51.
Zenith77 is offline
commonbullet
Veteran Member
Join Date: Oct 2005
Old 02-24-2007 , 15:17   Re: Module: Vdf trees
Reply With Quote #2

Cool ideas.

You could check if it's the last or first node with "vdf_get_first_node" or vdf_get_last_node", but I see the advantages of using your model in a loop.

The new version is going to change functions arguments a bit, since nodes and trees will be pointers, functions like vdf_get_next_node won't need to pass the tree i.e.

And although this means performance enhancement you'll have to be very careful - I crashed hl a couple of times when I was writing the new example script carelessly...

For the same reason it's better to detach nodes concept from numbers. I'll include a function to count nodes in a branch though.

Finally I'm including important stuff I had forgotten like destroying trees and setting keys/values functions.

Last edited by commonbullet; 02-24-2007 at 15:21.
commonbullet is offline
Send a message via ICQ to commonbullet Send a message via MSN to commonbullet
Zenith77
Veteran Member
Join Date: Aug 2005
Old 02-24-2007 , 18:02   Re: Module: Vdf trees
Reply With Quote #3

Sounds cool ^^. But are you adding the natives or no (sounds like you are, but didn't get an answer :-))
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
commonbullet
Veteran Member
Join Date: Oct 2005
Old 02-24-2007 , 18:51   Re: Module: Vdf trees
Reply With Quote #4

I guess I'll include this form:
Code:
vdf_is_first_node(node);
vdf_is_last_node(node);
actually, they could be easily replaced with these existent functions
Code:
!vdf_get_previous_node(node) // if true that's first node
!vdf_get_next_node(node) // if true that's the last node
but I guess the former sounds clearer.

And I'll include another one to way to count nodes in a branch. Maybe you can help me to find a better name to that.
Code:
vdf_count_branch_nodes(node)

Last edited by commonbullet; 02-24-2007 at 18:56.
commonbullet is offline
Send a message via ICQ to commonbullet Send a message via MSN to commonbullet
Zenith77
Veteran Member
Join Date: Aug 2005
Old 02-25-2007 , 10:13   Re: Module: Vdf trees
Reply With Quote #5

vdf_num_branch_nodes() lol?
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
commonbullet
Veteran Member
Join Date: Oct 2005
Old 02-25-2007 , 14:04   Re: Module: Vdf trees - 1.01
Reply With Quote #6

Update:

- updated sdk files and included auto load feature.
- nodes and trees are now pointers (thus should be used carefully)
- included the following natives.
Code:
vdf_set_node_key(node, const key[]);
vdf_set_node_value(node, const value[]);
native vdf_count_branch_nodes(node);
vdf_remove_tree(vdftree)
- included these stocks as suggested by Zenith
Code:
vdf_is_last_node(node)
vdf_is_first_node(node)

- The number of arguments of many natives has changed.
- Included a more consistent example – it covers almost all features - creatings a trees, saving, reading from file, representing trees structures in a menu interface.
I’ve spammed this example with comments as so to make it clear for everyone (not only for more experienced coders).

Thanks to Bail, Rukia, sawce and Zenith for helping me to improve it.

Last edited by commonbullet; 02-25-2007 at 14:53.
commonbullet is offline
Send a message via ICQ to commonbullet Send a message via MSN to commonbullet
Zenith77
Veteran Member
Join Date: Aug 2005
Old 02-25-2007 , 14:44   Re: Module: Vdf trees - 1.01
Reply With Quote #7

Yay. I love all these modules coming out (this and MemoryX). They've been a great aid to me :-).
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
commonbullet
Veteran Member
Join Date: Oct 2005
Old 03-01-2007 , 19:16   Re: Module: Vdf trees - 1.02
Reply With Quote #8

Update 1.02

- Included new search natives:
Code:

// creates a new search
vdf_create_search();

// sets up search
vdf_set_search(search, tree, const searchstr[], searchtype = 0, level =-1, ignorecase = 0);

// finds next node that matches search
vdf_find_next_match(search, startnode = 0); 

// closes search
vdf_close_search(search);
- Included this native for fast checking node depth:
Code:
native vdf_get_node_level(node);
- Detailed documentation in vdf.inc

- Included a plugin example for searching

- Fixed tree structure would be wrongly formed if vdf used k&r indentation style.
commonbullet is offline
Send a message via ICQ to commonbullet Send a message via MSN to commonbullet
Zenith77
Veteran Member
Join Date: Aug 2005
Old 03-01-2007 , 22:25   Re: Module: Vdf trees - 1.02
Reply With Quote #9

Yay.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
commonbullet
Veteran Member
Join Date: Oct 2005
Old 04-07-2007 , 15:09   Re: Module: Vdf trees - 1.03
Reply With Quote #10

1.03 Update

Lots of new stuff + fixes:

- It now requires tags for trees, nodes, and search. It tends to get safer from mistakes that could cause crashes, and it makes the source in pawn more clear (I think).
They are: VdfTree, VdfNode, VdfSearch; check the examples.

- Search may perform entire tree scanning by setting "*" as the look up string (this feature is useful to parse stuff).
- New find_in_branch native to look up a node in a branch
- New ‘shell’ sort nodes native, vdf_sort_branch. Sorts might be performed to nodes based on key/values (as strings or as numbers).
- New move nodes native (only moves nodes that are in the same tree): vdf_move_to_branch, vdf_move_as_child

- Included some ‘sugar’ to make it easier to lazy coders like me:
- vdf_get_node_value_num, vdf_get_node_value_float, vdf_get_node_value_vector – value string are converted to these ‘types’.
- vdf_set_node_value_num, vdf_set_node_value_float, vdf_set_node_value_vector – converts these ‘types’ to a string and stores in node value.

- Fixed append node bug, and some minor stuff.

Thanks to sawce for helping me with the code and for the Linux build.
commonbullet is offline
Send a message via ICQ to commonbullet Send a message via MSN to commonbullet
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 11:54.


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