PDA

View Full Version : GlobalList/Delimited List Helper DLL



Worm
03-06-2003, 12:46 PM
Allows you to sort Ascending/Descending, remove duplicates, change the first character of a string to Upper case, convert a string to all upper case, or lower case.

BIG THANKS to KPSmith for helping me with the testing.

Here is the info on the Functions. (http://www.warmuskerken.com/ams/wstringdll.txt)

Here is a sample project that uses the DLL. (http://www.warmuskerken.com/ams/wstring.zip)

kpsmith
03-06-2003, 01:44 PM
Ah... It was nothing.
Worm did all the work, I just tried to break it /ubbthreads/images/icons/smile.gif

This is a really cool .DLL!!

If your not sure what you would use this for check out the sample project and the light bulbs will turn on!

First the Sound control .dll and now this!!!

Thanks Worm

Corey
03-06-2003, 04:04 PM
Took a look. That's a spicy meatball! Worm strikes again...

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

Worm
03-07-2003, 02:22 PM
Thanks fo checking it out. Hopefully it'll be useful for others too.

kpsmith
03-13-2003, 07:22 AM
Worm,

Just wanted to say thanks again for this sort .dll

I finally got this implemented into my "real" project.

It saved me a whole lot of lines of code and it is much, much faster than using a list box to sort and two global lists to remove duplicates.

Not to mention I can also ensure the first letter of every item is capitalized.

Your Dll is now sorting and removing duplicates within a string of more than 3000 records and it finishes within seconds.

Worm
03-13-2003, 08:26 AM
Wooo Hooooo!

Couldn't have done it without you.

Lorne
03-13-2003, 08:59 AM
Hey Worm...what sort algorithm did you use? (Did you roll your own, or just use qsort?)

Worm
03-13-2003, 09:21 AM
Unforunately, eh-hem... a Bubble Sort /ubbthreads/images/icons/crazy.gif

I'd like to modify the code to use qsort, but I'm still learning, and bubble sort I can do. Thought I'd get it up and running and then go for optimization.

Any pointers (C++ pun intended) on the qsort, please send them my way.

Lorne
03-13-2003, 11:52 AM
qsort() is built into the standard library. /ubbthreads/images/icons/smile.gif As for pointers, Google (http://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&q=c%2B%2B+qsort&btnG=Google+Search) is your friend.

One thing to keep in mind is that the actual sorting algorithm(s) used by qsort() is implementation dependent. It could be quicksort, it could be quicker-sort, it could be an insertion sort. It's not necessarily the fastest (although I'd wager it would be faster than a bubble sort /ubbthreads/images/icons/wink.gif) but it's definitely a lot easier than rolling your own.

Be aware that, since the actual sorting algorithm depends on the compiler, qsort() may or may not use a stable sorting algorithm. ("Stable" in the sense that equivalent items retain their original positions in the list.)

For smallish lists of strings like this, I'd probably use an insertion sort if I didn't have access to C++, e.g. if I were coding the algorithm inside AutoPlay or something. Either that or a merge sort. All depends on the data.

There isn't any cut-and-dried "best" algorithm for everything, though...it all depends on the kind of data that will need to be sorted.

Lorne
03-13-2003, 11:58 AM
BTW, if you're using STL (the standard template library), the STL sort is even faster. Way, way faster.

More info (http://theory.stanford.edu/~amitp/rants/c++-vs-c/)

Worm
03-13-2003, 12:29 PM
Thanks for the references, Lorne. I'll look into the sorting methods and see if I can figure it out. I knew when I coded the sort that it wouldn't be the most optimized way to go and that I'd eventually go back and change it.

But as project deadlines won't wait on my learning curve, one does as he must.

I appreciate yours, Corey's and Brett's input and help. Thank you!

Corey
03-13-2003, 01:05 PM
Just for the record I much prefer to do stuff like this using a flash object. But then I'm .dll ign'nt so there you have it... It's supereasy to just whip up some actionscript and drop it in to do things like this, takes just a few minutes and performance seems superb so far. I have a bunch of stuff on this on the new Powertips CD.

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

feilong
03-14-2003, 04:39 AM
I think I also should thank Worm for creating this .DLL for this file is probably the basis of my project too.

I don't think i'm the only one if I say that Worm has been a great contributor to my project! Thanks Brad!

Martin_SBT
08-05-2003, 01:25 PM
Gents

Can i use that DLL to remove BLANK SPACE at begining and End of each items stored into a global list?? I have an Urgent need for something that would do that.

Please Help

Martin

Worm
08-05-2003, 01:57 PM
Honestly can't remember what funtions are built into it. I'd have to look at the source.

Why not pull the contents of the GL to a variable and do a string replace " ;;" with ";;" and ";; " with ";;". Then reinsert to the GL?

Martin_SBT
08-05-2003, 02:07 PM
Hi Worm

By reading your post you are saying that replacing spaces by spaces will do it??

Worm
08-05-2003, 02:16 PM
I guess I was thinking that the items in your list had a space at the beginning or end, not spaces. Let me take a look at the source tonight and I'll let you know.

Martin_SBT
08-05-2003, 02:17 PM
Worm

Sorry i understand what you are saying now! But i dont think its gonna work for me cause the Delimited items stored into my global list have multiple blank spaces at beginning and end of each delimited items and the number of blank spaces is not constant! It's because, the data have been parsed from a text file! All theses blank spaces are causing problems when i try to use one of these items as an ITEM DATA of a listbox. It looks like it is ignored if there are blank spaces... Any idea what i can do? If you had some functions in your DLL that could take care of it, that would be great!

Thanks in advance

Lorne
08-05-2003, 03:39 PM
If you know for sure that there won't be any double spaces in the valid part of the data, you could search for every pair of spaces, and replace them with an empty string.

Search for " " (2 spaces) replace with "".

Repeat that search & replace in a loop until " " is no longer found.

This will only work if there aren't any strings of spaces in the data that you want to keep. /ubbthreads/images/icons/smile.gif

aragonit
08-05-2003, 10:43 PM
You could knowingly 'pad' each and every string with a ";;" right and left, then replace " " with " " (two spaces with one) and do it in a while loop... so when ALL occurences of double spaces are eliminated you for sure know that there IS one ;; plus perhaps a space left and right. just replace ";; " and " ;;" and to make sure you got them all, again ";;" and you are done.