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

Looking for large numbers of entities


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ProdigySim
SourceMod Plugin Approver
Join Date: Feb 2010
Old 05-16-2010 , 12:33   Looking for large numbers of entities
Reply With Quote #1

The L4D2 project I'm working on currently has to search for a number of different entities on round start and perform various operations on them.

Right now, we simply loop through all possible Entity Indexes, check for classnames we want, and perform different operations based on that.

Recently, however, I've learned of the sdktools function "FindEntityByClassname," which will simply find entity instances of a given classname.

I want to know which of these will be more efficient to use.

I know FindEntityByClassname is a Valve function, so we don't know exactly how it works. My fear is that it just stores an index for the "First" entity given a classname, searches for a new one, then returns and stores the the new one. This means finding all Entities given a classname would be an O(n) operation, and we would end up with an one O(n) loop for every classname we want to deal with.

Whereas, by simply looping through all possible entities, we can do everything in a single O(n) loop. By using keyvalues and other optimizations, we can make all of our processing essentially O(1). However, this code is still fairly ugly to look at, and condensing all of our entity processing operations into a single loop would combine a lot of different modules of our plugin at once.

So, does anyone know time complexity or general efficiency information about FindEntityByClassname?
ProdigySim is offline
rhelgeby
Veteran Member
Join Date: Oct 2008
Location: 0x4E6F72776179
Old 05-17-2010 , 05:07   Re: Looking for large numbers of entities
Reply With Quote #2

As far as I know FindEntityByClassname has a starting index parameter so you can continue searching from the previous result. Making it ideal to use in loops.
__________________
Richard Helgeby

Zombie:Reloaded | PawnUnit | Object Library
(Please don't send private messages for support, they will be ignored. Use the forum.)
rhelgeby is offline
Send a message via MSN to rhelgeby
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:04.


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