Raised This Month: $ Target: $400
 0% 

Looking for large numbers of entities


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 02:47.


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