|
-
Aug 27th, 2002, 06:25 PM
#1
Thread Starter
Frenzied Member
-
Aug 27th, 2002, 06:46 PM
#2
Good Ol' Platypus
I already do my stuff in a way similar to that
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 27th, 2002, 09:15 PM
#3
PowerPoster
@Jotaf98: lol...
And soon you'll find out about objects and collections.
-
Aug 27th, 2002, 11:31 PM
#4
Good Ol' Platypus
Jotaf, I read over all your stuff and it's nice, but I wouldn't market it as a new technique, like Fox has implied (if I read it right, lol).
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 28th, 2002, 07:21 AM
#5
Junior Member
Sorry, I can't download the code right now, so I can't actually comment on it specifically, but 2 really quick methods I have used are:
1) Dynamic array with a bit smarter memory management. Each element has an "Exists" property and it allocates memory in large chunks so Redim calls are minimised (they are quite slow, especially when it is Redim Preserve).
2) Dictionary object: similar to the collection object, can be used by referencing the Microsoft Scripting Runtime. Usage is almost identical to a collection with a couple of changes (you can't directly copy paste, but it is intuitive). Stores objects by a key which can be anything - numbers, strings, UDTs etc. Behind the scenes it is just a hash table (like the collection). But it is a lot quicker.
Trying is the first step towards failure
-
Aug 28th, 2002, 08:27 AM
#6
Thread Starter
Frenzied Member
Lol of course you all do it in a similar way - I saw all your code samples just like everyone else and the only new thing about it is a small detail that makes it so you don't need to loop to look for inactive members: the stack of pointers to free slots in the array... the rest is exactly like most people do, and as to collections and objects, I made a few tests and this way it's a LOT faster 
Huh Rag it's exactly like your first technique except that you don't need to search for inactive objects...
-
Aug 28th, 2002, 09:19 AM
#7
Good Ol' Platypus
How do you know its not how I do it I did it that way in my Winsock multiple downloading program.. of course it didn't need that speed, but thats how it was 
Cool code though.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 28th, 2002, 09:30 AM
#8
Thread Starter
Frenzied Member
Heh ok... It's just that I never saw this in any program, and it has a huge advantage for such a small amount of code, so I thought I would share it.
-
Aug 28th, 2002, 09:41 AM
#9
Good Ol' Platypus
If I hadn't known about it, I would've used it after.. well, kind of.. errr... yeah..... disregard this post please
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 28th, 2002, 03:36 PM
#10
PowerPoster
I'm using this technique since ages.. also I made a little more complex management to delete items. Basically it just copies the last item of the array to the one that's going to be deleted, then cut the last item and change the 'pointer' to the new index. This way you don't even have to check for inactive members
-
Aug 29th, 2002, 09:38 AM
#11
Frenzied Member
well aren't you a little clever bunny, then
-
Aug 29th, 2002, 10:51 AM
#12
Frenzied Member
Thats how I do it, Fox. A quick swap, decrement the size (you dont even have to resize the array, just keep values for filled and total, and only resize when you exit, or need more space), and youre done. Linked Lists are also great for object managment, but since VB isnt very good at inheritance, and doesnt support templating at all, you would have to re-implement everything for every object type that you have.
Z.
-
Aug 29th, 2002, 11:30 AM
#13
Frenzied Member
I would have been tempted to use GlobalAlloc to allocate memory directly rather than use a safearray . . .
-
Aug 29th, 2002, 01:15 PM
#14
PowerPoster
I didn't say any word about ReDimming ^^
-
Aug 29th, 2002, 04:35 PM
#15
Frenzied Member
I didnt mean ReDim (unless you run out of space, of course). I was simply referring to holding a size value =).
Z.
-
Aug 29th, 2002, 04:50 PM
#16
Thread Starter
Frenzied Member
Heh I had never thought of that Fox, yes it's a great idea (I wonder how I never thought of that )
I also keep a size value and never redim the arrays (unless I need more memory). Sometimes what I do is redim it for more 100 items or something and keep the size valuelower so I don't have to redim it a lot of times
-
Aug 29th, 2002, 05:04 PM
#17
Frenzied Member
-
Aug 29th, 2002, 05:15 PM
#18
Thread Starter
Frenzied Member
Heh 
Hey what do you think if we wrote an article or something on these techniques... I had to figure them out by myself... what a waste of brain power
-
Aug 29th, 2002, 05:33 PM
#19
Lively Member
JOTAF
A tutorials sounds good since I have no idea wot u guys r on about 
Dan
-
Aug 29th, 2002, 06:29 PM
#20
Good Ol' Platypus
Uh-oh, another Jotaf community project... lol
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 29th, 2002, 06:36 PM
#21
Thread Starter
Frenzied Member
Lol com'on sas, you're talking like if I ever did something like that (or do it all the time)
-
Aug 29th, 2002, 08:11 PM
#22
Good Ol' Platypus
You made a community project out of your particle systems thing, we all chipped in
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Nov 18th, 2002, 12:02 PM
#23
Addicted Member
It is now mid-November. I think I read this thread in September. I downloaded your file and read some of your comments. Didn't really click at the time but what did make sense "in the back of my mind" was pulling an element from the top. It's about 2 days now that I've had my own stack-based recycling system running. I use 2 stacks, and each has its own pointer. It is 'your original idea' that sparked my system. Thanks
-
Nov 18th, 2002, 04:27 PM
#24
Thread Starter
Frenzied Member
-
Nov 18th, 2002, 06:28 PM
#25
Good Ol' Platypus
Yeah, I was just about to call you the genie (only comes when somebody calls him )
Catch you later, I suppose!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Nov 18th, 2002, 06:34 PM
#26
Thread Starter
Frenzied Member
Yeah, rub the lamp and I always show up... hmm... my e-mail is [email protected] , I'm usually online since I have a nice cable connection hehe
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|