containers

Shrink-wrap and center a container for inline-block elements

微笑、不失礼 提交于 2019-11-26 14:44:35
问题 I have a bunch of inline-block elements over several lines which I'd like to center horizontally. The inline-block elements all have the same fixed size, but I'd like the centering to be able to handle page resizing and adding or removing elements. I've stripped down the html/css and removed the attempt at centering for clarity. It's at http://jsfiddle.net/fe25H/1/ If you resize the results window so that the third inline-block element drops down, the container fills the width and we get this

How can I get all controls from a Form Including controls in any container?

做~自己de王妃 提交于 2019-11-26 14:38:43
问题 I need, for example, a way to disable all buttons in a form or validate all textboxes' data. Any ideas? Thanks in advance! 回答1: The simplest option may be to cascade: public static void SetEnabled(Control control, bool enabled) { control.Enabled = enabled; foreach(Control child in control.Controls) { SetEnabled(child, enabled); } } or similar; you could of course pass a delegate to make it fairly generic: public static void ApplyAll(Control control, Action<Control> action) { action(control);

Do STL iterators guarantee validity after collection was changed?

 ̄綄美尐妖づ 提交于 2019-11-26 13:49:24
问题 Let's say I have some kind of collection and I obtained an iterator for the beginning of it. Now let's say I modified the collection. Can I still use the iterator safely, regardless of the type of the collection or the iterator? To avoid confusion, here is the order of operations I talk about: Get an iterator of the collection. Modify the collection (obviously not an element in it, but the collection itself). Use the iterator obtained at step 1. Is it stil valid according to STL standard?!

Is there a sorted collection type in .NET?

穿精又带淫゛_ 提交于 2019-11-26 13:46:50
问题 I'm looking for a container that keeps all its items in order. I looked at SortedList, but that requires a separate key, and does not allow duplicate keys. I could also just use an unsorted container and explicitly sort it after each insert. Usage: Occasional insert Frequent traversal in order Ideally not working with keys separate from the actual object, using a compare function to sort. Stable sorting for equivalent objects is desired, but not required. Random access is not required. I

Why does storing references (not pointers) in containers in C++ not work?

江枫思渺然 提交于 2019-11-26 12:44:40
问题 In my program I have a STL set. set<string> myStrings; To improve the efficiency of my code I changed it to hold, only pointers. (I don\'t need actual string copies to be stored.) set<string*> myStrings; I have read that it is a good practice to substitute pointers with references when possible. (Of course, only if the actual functionality of a pointer is not needed.) set<string&> myStrings; The latter one gives me a lot of compiler errors, though. Why is it not possible to use references as

Heterogeneous containers in C++

南楼画角 提交于 2019-11-26 12:24:19
I saw this nice graphic which classifies which STL container would suit based on different requirements of data such as: -- Fixed Size Vs Variable size -- Data of same tyme Vs different type -- Sorted Vs unsorted data -- Sequential Vs random access http://plasmahh.projectiwear.org/cce_clean.svg I notice in that image, that C++ STL there is no container which is Variable Size Heterogenous (data of different types). Doesn't C++ have something for this? PS - There can be many permutations made out the different properties of the containers and many others too might not be provided in STL. Fire

Container Class / Library for C [closed]

巧了我就是萌 提交于 2019-11-26 12:03:19
Does anyone know of any C container libraries? I am looking for something which gives standard implementations of linked lists, arrays, hash tables etc, much in the same way as the C++ STL does. Key concerns are: Client code should be able to create containers for multiple different data types without modifying the library. The interface for creating and using the containers should be intuitive. I just came across SGLIB while looking for a C implementation of a map/dictionary container. Unfortunately, no map but it seems to include the containers you asked about. I have no idea how good it is.

Abstract factory pattern on top of IoC?

核能气质少年 提交于 2019-11-26 11:48:30
问题 I have decided to use IoC principles on a bigger project. However, i would like to get something straight that\'s been bothering me for a long time. The conclusion that i have come up with is that an IoC container is an architectural pattern, not a design pattern. In other words, no class should be aware of its presence and the container itself should be used at the application layer to stitch up all components. Essentially, it becomes an option, on top of a well designed object-oriented

What&#39;s the best way to iterate over two or more containers simultaneously

纵饮孤独 提交于 2019-11-26 11:35:59
C++11 provides multiple ways to iterate over containers. For example: Range-based loop for(auto c : container) fun(c) std::for_each for_each(container.begin(),container.end(),fun) However what is the recommended way to iterate over two (or more) containers of the same size to accomplish something like: for(unsigned i = 0; i < containerA.size(); ++i) { containerA[i] = containerB[i]; } Rather late to the party. But: I would iterate over indices. But not with the classical for loop but instead with a range-based for loop over the indices: for(unsigned i : indices(containerA)) { containerA[i] =

What is an iterator&#39;s default value?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 11:28:25
问题 For any STL container that I\'m using, if I declare an iterator (of this particular container type) using the iterator\'s default constructor, what will the iterator be initialised to? For example, I have: std::list<void*> address_list; std::list<void*>::iterator iter; What will iter be initialised to? 回答1: By convention a "NULL iterator" for containers, which is used to indicate no result, compares equal to the result of container.end() . std::vector<X>::iterator iter = std::find(my_vec