Old 01-14-2013, 06:14 AM   #1
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,353
Default List import library

Here's a suite of Jesusonic functions for managing lists of items in memory...

https://stash.reaper.fm/v/15072/ixlist.zip.zip

There's a txt file in the zip that hopefully details all the safe functions. The safe functions are mostly wrappers around various unsafe functions which don't do any safety checks.

I've been testing as I go but I haven't used it in battle yet so there could be bugs (I hope not though ).

Comments, suggestions and bug reports are welcome.

Last edited by IXix; 01-14-2013 at 07:06 AM.
IXix is offline   Reply With Quote
Old 01-14-2013, 07:23 AM   #2
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,353
Default

Something that I'm not sure how to handle...

If the list size is limited and the item count has reached the limit, what should happen if you try to add another item? Currently it just fails but I'm wondering if perhaps this behaviour should be configurable. Perhaps adding a new item to a full list should knock an existing item out of the list, but which item should go?

I can think of a few possibilities:
  • Do nothing (current behaviour.)
  • Push subsequent items causing last item to be removed.
  • Push prior items causing first item to be removed.
  • Overwrite an existing item ie. List_InsertAtIndex(4) would replace item 4, List_AddToStart() would replace the first, List_AddToEnd() would replace the last.

I guess I could make it so you can specify which method you want to use. Any thoughts?
IXix is offline   Reply With Quote
Old 01-15-2013, 12:13 PM   #3
captain_caveman
Human being with feelings
 
captain_caveman's Avatar
 
Join Date: Dec 2011
Posts: 999
Default

Nice work, I'll give it a whirl when I get a chance. Thanks.

Re the question, I don't know. It would seem more natural to have it push prior items since implementing a fixed size list would probably mean you're only interested in the most recent. Cue a bazillion examples of where that would not be the case...
captain_caveman is offline   Reply With Quote
Old 01-15-2013, 01:56 PM   #4
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,353
Default

Quote:
Originally Posted by captain_caveman View Post
Re the question, I don't know. It would seem more natural to have it push prior items since implementing a fixed size list would probably mean you're only interested in the most recent. Cue a bazillion examples of where that would not be the case...
I've just uploaded a new version. You can now specify which behaviour you want (the default is still to just do nothing and return an error). I've also added a few new functions that I found I was missing while using the list in an actual plugin.

I'm pretty pleased with how it's working so far

edit: Oh and I've documented the unsafe functions too.
IXix is offline   Reply With Quote
Old 08-06-2014, 01:41 PM   #5
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,353
Default

Quote:
Originally Posted by Veto View Post
there's a really tiny bug at line 695 (the semicolon before the ternary operator)
So there is! Strange, it's not in my local copy. Fixed now. Thanks.
IXix is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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 -7. The time now is 03:59 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.