Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 10-12-2012, 07:34 AM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,742
Default

It depends on the implementation of list. list::empty() is guaranteed to be a constant time check, where list::size() can be linear time. In practice most implementations of list are such that both are constant time operations since the size is cached.

The reason an implementation might choose to have list::size() be a linear time operation would be so list::splice() is a constant time operation rather than having to count how many nodes were spliced to update the count. The only implementations I know of that did it that way for that specific reason are the sgi / STLPort variations which we don't use.

For all standard library containers it is considered more correct to check for empty() rather than size() == 0, but I probably wouldn't refactor working code to change just that unless it was to fix an actual performance problem versus a theoretical one.
Reply With Quote
 

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 -4. The time now is 11:35 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3