containers

What's the most standard/generic way to zip a traversable with a list?

*爱你&永不变心* 提交于 2019-11-28 12:27:14
Traversable is in a sense the class of containers whose structure has a “path” (that can correspond to a list), the elements on which can be modified without dissolving the structure. Hence zipTrav :: Traversable t => t a -> [b] -> Maybe (t (a,b)) zipTrav = evalStateT . traverse zp where zp a = do bs <- get case bs of [] -> lift Nothing (b:bs') -> put bs' >> return (a,b) However, that list-state traversal seems a bit hackish and likely not the most efficient way to do it. I'd suppose there would be a standard function that accomplished the above or a more general task, but I can't figure out

Access to container by his hostname from host-machine

和自甴很熟 提交于 2019-11-28 12:21:02
问题 I have some docker containers which united single dockers overlay network. Under this network every containers access by hostname (of container). But I cant access to container by hostname from host-mashine (my real host). How I can get access to container by docker container hostname from my real machine? 回答1: You can simply add 127.0.0.1 <hostname_inside_docker> to your hosts file (on your local machine 回答2: You can do that by launching your own DNS resolver container. docker run -d --name

splice() on std::list and iterator invalidation

笑着哭i 提交于 2019-11-28 12:06:18
The 3-argument form of list::splice() moves a single element from one list to the other. SGI's documentation explicitly states that all iterators, including the one pointing to the element being moved remain valid. Roguewave's documentation does not say anything about iterator invalidation properties of splice() methods, whereas the C++ standard explicitly states that it invalidates all iterators and references to the element being spliced. splicing() in practice works as defined by SGI, but I get assertion failure (dereferencing invalid iterator) in debug / secure SCL versions of microsoft's

How to select an object in a flex HGroup?

…衆ロ難τιáo~ 提交于 2019-11-28 11:47:01
问题 I have a button to create a image object every time its clicked and add that image object in to the Hgroup. The Hgroup could contain a few image objects. And another button to rotate the object. What I want to do : To be able to select a object. So that selected object can be rotated 90 degrees about a point each time the rotate button is clicked. Also want to limit the number of items added in the container/Hgroup.(Must be with the border) Which is the best container(list, border container,

RSelenium on docker: where are files downloaded?

痴心易碎 提交于 2019-11-28 08:58:33
问题 I am using Selenium using a docker image: require(RSelenium) if (length(system("docker ps -l", intern = TRUE))<2) try({system("docker run -d -p 4445:4444 selenium/standalone-firefox:2.53.0")}) It works, I can connect to any url and navigate. However when I click a button to download a file, it sometimes saves it (partially, saved as xxxxxxx.csv.part ) to /tmp/mozilla_mozillaUser0 , and sometimes to ... nowhere, or maybe another location I cannot find... Is there a reason for that? Also I

What is the C++ equivalent of inheriting a Java collection interface (Set, Map, List etc.)? Or extending AbstractCollection?

邮差的信 提交于 2019-11-28 08:46:09
问题 I've started coding in C++, coming from a Java background (actually I'd studied C++ at my university, but we never got to the STL etc.) Anyway, I've gotten to the point where I'm arranging data in all sorts of collections, and I immediately tell myself "Ok, this is a kind of a Set; and this is a List, or an ArrayList; and this is a map etc." In Java, I would simply have whatever class I'm writing implement the Set or Map or List interface; but I would probably not go as far as inheriting

How do I mount a Docker volume while using a Windows host?

无人久伴 提交于 2019-11-28 08:44:18
Mounting a Docker volume while being under a Windows host, has been a huge pain for me, and I could not get it to work. Currently I got the following simple Dockerfile: FROM php:5-apache RUN apt-get update When I build an image from it, and start a container docker build -t phisch:dev . docker run phisch:dev the container starts properly. But when I am trying to mount a volume, docker run -v /c/Users/phisch/dev/htdocs:/var/www phisch:dev the following message will be displayed: C:\Users\phisch\dev>docker run -v /c/Users/phisch/dev/htdocs:/var/www phisch:dev no such file or directory docker:

C++ STL: Which method of iteration over a STL container is better?

不羁的心 提交于 2019-11-28 08:30:37
This may seem frivolous to some of you, but which of the following 2 methods of iteration over a STL container is better? Why ? class Elem; typedef vector<Elem> ElemVec; ElemVec elemVec; // Method 0 for (ElemVec::iterator i = elemVec.begin(); i != elemVec.end(); ++i) { Elem& e = *i; // Do something } // Method 1 for (int i = 0; i < elemVec.size(); ++i) { Elem& e = elemVec.at(i); // Do something } Method 0 seems like cleaner STL, but Method 1 achieves the same with lesser code. Simple iteration over a container is what appears all over the place in any source code. So, I'm inclined to pick

STL map onto itself?

▼魔方 西西 提交于 2019-11-28 08:29:30
I'd like to create a std::map that contains a std::vector of iterators into itself, to implement a simple adjacency list-based graph structure. However, the type declaration has me stumped: it would seem you need the entire map type definition to get the iterator type of said map, like so: map< int, Something >::iterator MyMap_it; // what should Something be? map< int, vector<MyMap_it> > MyMap_t; Is there some sort of partial map iterator type I can get with just the key type, so I can declare the full map? You could use forward declaration of a new type. class MapItContainers; typedef map<int

Do java flags Xms and Xmx overwrite flag XX:+UseCGroupMemoryLimitForHeap?

情到浓时终转凉″ 提交于 2019-11-28 08:09:10
问题 I'm running a containerized java application in Kubernetes. In order to make the jvm reserve memory according to the container specifications, the flags -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap must be set. If both those flags are set along with Xms and Xmx flags, what would the behavior of the jvm be? Do one flag overwrite the other? For example, if we had java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -Xms -Xms2500M -Xmx2500M -jar myjar.jar