capacity

Can pop_back() ever reduce the capacity of a vector? (C++)

那年仲夏 提交于 2020-01-03 09:41:27
问题 According to the C++ standard, is std::vector<T>::pop_back() ever allowed to reduce the capacity of the vector? I am asking because I would like to have a guarantee, that the following code will not throw an out of memory exception: my_vec.pop_back(); if (...) my_vec.push_back(...); Assume that my_vec is an std::vector<int> . I guess there are three possibilities: Yes, this can happen according to both C++03 and C++11. No, C++11 prohibits this (but C++03 does not). No, both C++03 and C++11

Is it possible to give a python dict an initial capacity (and is it useful)

僤鯓⒐⒋嵵緔 提交于 2019-12-30 05:59:33
问题 I am filling a python dict with around 10,000,000 items. My understanding of dict (or hashtables) is that when too much elements get in them, the need to resize, an operation that cost quite some time. Is there a way to say to a python dict that you will be storing at least n items in it, so that it can allocate memory from the start? Or will this optimization not do any good to my running speed? (And no, I have not checked that the slowness of my small script is because of this, I actually

NSMutableArray initWithCapacity nuances

不打扰是莪最后的温柔 提交于 2019-12-27 20:14:54
问题 Does anyone have advice on how to best initialize an NSMutableArray when it comes to dictating the capacity? The documentation mentions that "...even though you specify a size when you create an array, the specified size is regarded as a “hint”; the actual size of the array is still 0." So... 1) If I init with a greater capacity than I typically use, do I not have to worry about wasted memory? 2) If I init with a capacity typically lower than what I use, do I have to worry about heavier

NSMutableArray initWithCapacity nuances

自古美人都是妖i 提交于 2019-12-27 20:08:29
问题 Does anyone have advice on how to best initialize an NSMutableArray when it comes to dictating the capacity? The documentation mentions that "...even though you specify a size when you create an array, the specified size is regarded as a “hint”; the actual size of the array is still 0." So... 1) If I init with a greater capacity than I typically use, do I not have to worry about wasted memory? 2) If I init with a capacity typically lower than what I use, do I have to worry about heavier

ArrayList capacity size increasing strange behaviour

偶尔善良 提交于 2019-12-24 02:52:36
问题 When ArrayList wants to store more elements than actual capacity it increases the capacity. It is very cost efficient operation since we actually copy all data from previous ArrayList to new ArrayList with larger capacity. However I wonder that maybe some operations with capacity are not proceeded when ArrayList just needs more space - but much before. I wonder what takes such long time for "slow indexes" from my output and increasing capacity is my only one idea. Here is my code: import java

Getting Numbers From A CFDictionary For Use In Calculations, iPhone

旧街凉风 提交于 2019-12-23 05:36:13
问题 I found this in my travels: http://www.opensource.apple.com/source/IOKitUser/IOKitUser-502/ps.subproj/IOPSKeys.h How would I get the values (as a number) of: #define kIOPSMaxCapacityKey "Max Capacity" and #define kIOPSDesignCapacityKey "DesignCapacity" I want to be able to use them throughout my app. What do I need to add to my project and how do extract the numbers? Many thanks, Stuart 回答1: Once you know where the actual dictionary is that it's storing these values, you can access the value

New field under Azure DevOps (VSTS/TFS) iteration capacity tab

匆匆过客 提交于 2019-12-22 15:11:12
问题 I am looking for a method to customize the capacity tab to include new field for each team member where i can specify the buffer time for each one during the sprint. Is it possible to add such new field entry under capacity tab or not? 回答1: This isn't possible right now. You can help upvote this to increase visibility of this need to the product team in developer community: https://developercommunity.visualstudio.com/idea/365553/vsts-custom-team-capacity-activity-as-well-as-cust.html 来源:

Request-URI Too Large [duplicate]

家住魔仙堡 提交于 2019-12-19 05:33:07
问题 This question already has answers here : How do I resolve a HTTP 414 “Request URI too long” error? (5 answers) Closed 5 years ago . Got this error on a big $_GET query in size ~9 000 symbols (they are divided into ~10 variables). Request-URI Too Large The requested URL's length exceeds the capacity limit for this server. What is a workaround for this problem? 回答1: There is no workaround if you want pass all these info with GET without change server configuration. Other solutions: Use POST

Should a .NET generic dictionary be initialised with a capacity equal to the number of items it will contain?

不想你离开。 提交于 2019-12-18 04:38:09
问题 If I have, say, 100 items that'll be stored in a dictionary, should I initialise it thus? var myDictionary = new Dictionary<Key, Value>(100); My understanding is that the .NET dictionary internally resizes itself when it reaches a given loading, and that the loading threshold is defined as a ratio of the capacity. That would suggest that if 100 items were added to the above dictionary, then it would resize itself when one of the items was added. Resizing a dictionary is something I'd like to

How does StringBuilder's capacity change?

若如初见. 提交于 2019-12-17 16:41:33
问题 When I have an empty StringBuilder with a capacity of 5 and I write "hello, world!" to it, does the C# standard specify the new capacity of the StringBuilder ? I have a vague memory that it's twice the new string's length (to avoid changing the capacity with every new appended string). 回答1: Depends what version of .NET you're talking about. Prior to .NET 4, StringBuilder used the standard .NET strategy, doubling the capacity of the internal buffer every time it needs to be enlarged.