Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 23:42

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Custom container

Discussion on Custom container within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1



 
Shawak's Avatar
 
elite*gold: 0
The Black Market: 259/0/0
Join Date: Apr 2010
Posts: 10,289
Received Thanks: 3,613
Post Custom container

Hey guys,

so i'm in the search of a container which fulfill following criteria:

- add elements sorted with a complexity of O(Nlog(size+N))
- erasing elements at position N with a complexity of O(1)
- returning elements at a range from to with a complexity of O(1)

so it's likely almost the same as the sdt::set<T> or sdt::multiset<T> just returning their elements with a given offset should be possible, any idea how to aquire this?

regards
Shawak is offline  
Old 06/11/2017, 03:43   #2
 
atom0s's Avatar
 
elite*gold: 0
Join Date: May 2013
Posts: 175
Received Thanks: 125
Probably best to roll your own.

For sorted adding, std::sort itself guarantees to be O(N log(N)) according to the C++11/14 standards. (Using N == last - first as the comparison.)


For O(1) removal, you can do similar to how vector removal can be done via:
- std::move -> pop_back


This usually is done on an unordered vector of some sort. You can also look into how std::list::erase works as it's guaranteed to be O(1) according to the standards.
atom0s is offline  
Thanks
1 User
Old 06/11/2017, 12:12   #3



 
Shawak's Avatar
 
elite*gold: 0
The Black Market: 259/0/0
Join Date: Apr 2010
Posts: 10,289
Received Thanks: 3,613
The problem is that a set::set::insert takes O(Nlog(size+N)) where N = number of elements to insert, so if I only want to inset one elemnt it results in O(log(size)). A std::sort takes O(Nlog(N)) where N = std::distance(first, last) which is in comparison way too much, sine my containers contain around 10 million elements.
Shawak is offline  
Reply


Similar Threads Similar Threads
[CUSTOM SALE] PokeMMO! Custom Bots, Exp Leveling Bot, Shiny Catcher! [CUSTOM SALE]
04/08/2014 - Trading - 90 Replies
Update: 2013-05-20 BOT IS NOW FULLY AIO SUPPORTS ALL LOCATIONS IN POKEMMO!! Auto-leveling bot: Supports PP healing Supports Death pokemon healing Supports death pokemon switching Supports walking to healing Fully flawless & catches shinies!!!
[Service] DLC Container -> Premium Container! Download now with FullSpeed!
03/25/2013 - elite*gold Trading - 1 Replies
http://i.epvpimg.com/aLqtg.png http://i.epvpimg.com/tjL9c.png http://i.epvpimg.com/O4LRb.png
[BETA]Beta-Max Online ~ 120 CAP ~ D13 ~ Custom Events ~ Custom Quests ~ Custom Areas
03/25/2012 - SRO PServer Advertising - 109 Replies
Hello there, I would like to announce the BETA opening of Astro Server, We are here for the community not for competition. We don't care if we are #1 or #1001. The BETA will last one week, to find any small bugs that may still exist. During this time users will receive 5000 Wonga as soon as you register this is part of the BETA test. Also users will be rewarded for helping when we go live, Which you can find more information on this at the forum. Please be aware after the BETA ends...
Beta-Max Online ~ 120 CAP ~ D13 ~ Custom Events ~ Custom Quests ~ Custom Areas
03/19/2012 - SRO PServer Advertising - 6 Replies
Fantastic Server. If reliablility is what you want then Beta-Max is for you. Unique PVP Battles - Pets - Items - Quests - Jobs - Wonga and so much more Server Details: Level Cap: 120 Skill Cap: 120 Chinese Mastery Cap: 360 European Mastery Cap: 240 Item Degree: 13th Degree Active Areas: All (Including Jupiter)



All times are GMT +1. The time now is 23:43.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.