containers

Complexity requirements for std::deque::push_back/front

对着背影说爱祢 提交于 2019-11-30 12:34:52
As a result of this question from a few days ago there are a few things that have been bugging me about the complexity requirements for std::deque::push_back/push_front vs the actual std::deque implementations out in the wild. The upshot of the previous question was that these operations are required to have O(1) worst case complexity. I verified that this was indeed the case in c++11 : from 23.3.3.4 deque modifiers, refering to insert, push/emplace front/back Complexity: The complexity is linear in the number of elements inserted plus the lesser of the distances to the beginning and end of

C++ algorithm like python's 'groupby'

╄→尐↘猪︶ㄣ 提交于 2019-11-30 11:59:21
Are there any C++ transformations which are similar to itertools.groupby() ? Of course I could easily write my own, but I'd prefer to leverage the idiomatic behavior or compose one from the features provided by the STL or boost . #include <cstdlib> #include <map> #include <algorithm> #include <string> #include <vector> struct foo { int x; std::string y; float z; }; bool lt_by_x(const foo &a, const foo &b) { return a.x < b.x; } void list_by_x(const std::vector<foo> &foos, std::map<int, std::vector<foo> > &foos_by_x) { /* ideas..? */ } int main(int argc, const char *argv[]) { std::vector<foo>

From within a view controller in a container view, how do you access the view controller containing the container?

不羁的心 提交于 2019-11-30 11:44:22
问题 This is tricky to word but I have a view controller (vc1) that contains a container view (I'm using storyboards). Within that container view is a navigation controller and a root view controller (vc2). From within the vc2 how can I get access to vc1? Or, how do I pass vc1 to vc2? (baring in mind that I'm using storyboards). 回答1: You can use the prepareForSegue method in Vc1 as an embed segue occurs when the ContainerViewController is made a child. you can pass self as an obj or store a

Can 'iterator' type just subclass 'const_iterator'?

不羁岁月 提交于 2019-11-30 11:29:53
After another question about iterators I'm having some doubts about custom containers. In my container, iterator is a subclass of const_iterator , so that I get conversion from non-const to const "for free". But is this allowed or are there any drawbacks or non-working scenarios for such a setup? Yes, this is fine. This is how VC10's implementation of the iterators for vector are structured, for example. See _Vector_iterator and _Vector_const_iterator in <vector> . By the way, writing iterators is hard. It's worth your time to learn and use the boost::iterator library. Subclassing seems

Is docker a solution for making application cross platform?

女生的网名这么多〃 提交于 2019-11-30 11:25:30
I'm getting started with docker by reading some blogs and introduction material. My understanding is docker can wrap a single application into a standardized container. The container provides a sandbox, all the necessary resources the application needs to run, and the application inside always live within that container. That means I can ship the container to everywhere( different kind of OS or even cloud platforms ) and it should still can be run correctly. If my understanding is correct, then does that mean maybe microsoft can wrap their office suits into a container and I can install and

Multiple Docker containers, same image, different config

半世苍凉 提交于 2019-11-30 11:22:45
问题 I'm totally new to Docker so I appreciate your patience. I'm looking for a way to deploy multiple containers with the same image, however I need to pass in a different config (file) to each? Right now, my understanding is that once you build an image, that's what gets deployed, but the problem for me is that I don't see the point in building multiple images of the same application when it's only the config that is different between the containers. If this is the norm, then I'll have to deal

Can we deploy an asp.net mvc 4 app to docker with windows container?

假装没事ソ 提交于 2019-11-30 10:21:01
All the demo I saw lately are oriented Asp.net core (I am not sure how it's stable and functional, as it didn't contain all asp.net features), as Windows server 2016 support containers (and docker), should we be able to deploy an asp.net mvc 4.0 app ? Yes. You can use microsoft/windowsservercore or microsoft/iis as a base image, install full ASP.NET and run your 'legacy' .NET apps in containers on Windows. You can do it now with Windows 10 and Server 2016 TP5, but the RTM (expected next week at Ignite) should be more stable. I've shown this by Dockerizing the old Nerd Dinner showcase app . You

Docker error cannot delete docker container, conflict: unable to remove repository reference

邮差的信 提交于 2019-11-30 10:07:40
问题 I want to remove the container at Docker, but an error occurs when you want to delete My next step before removing the container, see the list of existing container sts@Yudi:~/docker$ sudo docker ps -as CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE 78479ffeba5c ubuntu "/bin/bash" 42 hours ago Exited (0) 42 hours ago sharp_wescoff 81 B (virtual 187.7 MB) 0bd2b54678c7 training/webapp "python app.py" 5 days ago Exited (0) 5 days ago backstabbing_ritchie 0 B (virtual 323.7 MB)

C++ How to create a heterogeneous container

此生再无相见时 提交于 2019-11-30 09:49:00
I need to store a series of data-points in the form of (name, value), where the value could take different types. I am trying to use a class template for each data-point. Then for each data-point I see, I want to create a new object and push it back into a vector. For each new type, I need to create a new class from the template first. But I can not store the objects created in any vector, since vectors expect the same type for all entries. The types I need to store can not be fitted in a inheritance hierarchy. They are unrelated. Also there can be more types created in future, and I do not

Is it safe to move elements of a initializer list? [duplicate]

雨燕双飞 提交于 2019-11-30 09:18:52
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: initializer_list and move semantics In this code: #include <vector> #include <initializer_list> template<typename T> class some_custom_container : public std::vector<T> { public: some_custom_container(const std::initializer_list<T>& contents) { for (auto& i : contents) this->emplace_back(std::move(i)); } }; class test_class {}; int main() { test_class a; some_custom_container<test_class> i = { a, test_class(), a