containers

Disposing scopedregionmanager

Hi I am having some dificulties regarding my application design. I have a module that is resposible for creating scopedregionmanagers based on the outside xaml in which i define regions. When I inject those outside xaml-s i create scoped regionmanagers and then i register them in the container: detailregionmanager = regionmanager1.Regio...

Create a C++ container that contain the filenames within a directory

I need to generate a container of filenames within a directory in C++ and it must be cross platform compatible. Someone recommended using the WIN32_FIND_DATA data structure. Is this the best option and if so how would I implement it? The user will not enter the filenames, but rather the C++ function will automatically search the directo...

How to extract the contents of an OLE container?

I need to break open a MS Word file (.doc) and extract its constituent files ('[1]CompObj', 'WordDocument' etc). Something like 7-zip can be used to do this manually but I need to do this programatically. I've gathered that a Word document is an OLE container (hence why 7-zip can be used to view its contents) but I can't work out how to...

How to create a generic container with unknown member functions?

Dear reader, I noticed that I'm often in the need of a container class. For example when working on a particle system, I create a container class Particles which has a member vector<Particle*>. Then I call: Particles* my_particles like my_particles->draw(), and in the Particles.draw() I iterator over the vector<Particle*> and call draw...

STL container function return values

When looking over the member functions of the STL containers, an odd thought occurred to me. Why don't functions like std::vector<T>::push_back(T) not have an (optional) return value (iterator or even a reference to the appended object)? I know std::string functions like insert and erase return iterators, but that's for obvious reasons. ...

Save files (pictures, music, movies) in a Container file.

I am currently learning C# during my studies and I am writing a small movie database application in it. I know its not good to save pictures (etc) inside the database, especially when adding movie covers that are rather big. But I don't want the files to just get saved in a folder as this creates a mess if more and more movies are added ...

set_union with multiset containers?

What's the return of the algorithm std:set_union when one or both input containers are multisets with duplicated objects? Do dups get lost? Let's suppose for example: multiset<int> ms1; ms1.insert(1); ms1.insert(1); ms1.insert(1); ms1.insert(2); ms1.insert(3); multiset<int> ms2; ms2.insert(1); ms2.insert(1); ms2.insert(2); ms2.insert(...

What's the best way to sum the result of a member function for all elements in a container?

Let's say I have the following object: struct Foo { int size() { return 2; } }; What's the best way (most maintainable, readable, etc.) to get the total size of all objects in a vector<Foo>? I'll post my solution but I'm interested in better ideas. Update: So far we have: std::accumulate and a functor std::accumulate and a la...

C++ How to create a heterogeneous container

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...

Which STL container for ordered data with key-based access?

Let's say I have a collection of Person objects, each of which looks like this: class Person { string Name; string UniqueID; } Now, the objects must be stored in a container which allows me to order them so that I can given item X easily locate item X+1 and X-1. However, I also need fast access based on the UniqueID, as the coll...

How to create and maintain a multi-language project ?

Hi, i am planning to make a multi language application in C# and was wondering what is the best way to handle the follow: The container for the languges; Best approchs to read/change once initiated/requested; As the program grows so does the the text for each language what do you usually do and recommend as best pratice; What sort of ...

C++ container class type conversion

Say, i got Set<DerivedClass*> set1; and i got Set<BaseClass*> set2; how do i do this? Set<BaseClass*> set3 = set1.substract(set2); //static cast! ...

I'd like to know what's going on this Python program. I've included the code.

Here's the code: http://paste.pocoo.org/show/238093/ My main questions right now are: Is Line 37 mainly the gist of this program? And does it simply calculate this once and then print the result? Ex: self.start + key*self.step with start=1, key=4, step=2 [prints 9] where does the variable 'value' actually come into play here? Line 39....

C++ container question

Hello! I was looking for some suitable 2D element container. What I want is the ability to iterate through every element of the container using, for example BOOST_FOREACH and I also would like to have an ability to construct subview (slices / subranges) of my container and, probably iterate through them too. Right now I am using boost:...

Architectural C++/STL question about iterator usage for O(1) list removal by external systems.

This is a pretty straightforward architectural question, however it's been niggling at me for ages. The whole point of using a list, for me anyway, is that it's O(1) insert/remove. The only way to have an O(1) removal is to have an iterator for erase(). The only way to get an iterator is to keep hold of it from the initial insert() or t...

Do I need to define `operator==` to use my class with standard containers?

I'd like clarification on the C++ standard, specifically where it says (my interpretation) in section 20.1.3 that "for class T and an instance of class T called x, T(x) must be equivalent to x" for the class to work with standard containers. I couldn't find a definition of 'equivalent'. Does this mean that I have to define operator== a...

ctype and strings and containers

Is there any reason that the ctype facet functions (is,scan_is,scan_not only support plain char pointer, and not iterator based containers, like std::string or even a std::vector... then one could write: const ctype<char>& myctype = use_facet<std::ctype<char> >(locale("")); string foo_str = "hi there here is a number: 748574 and text ag...

Custom nested container control

I'm writing a custom control which consists of a FlowLayoutPanel nested in a normal Panel. The FlowLayoutPanel is internal to the class, and shouldn't be able to be viewed by the designer (unlike a Tab, which has its individual properties exposed.) Any control the designer adds to the Panel should instead be added to the FlowLayoutPanel....

Does myVector.erase(myObject) call delete on myObject?

Similar to this question but with objects instead of pointers. If I have the following code Foo f; vector<Foo> vect; vect.push_back(f); vect.erase(vect.begin()); Where does my object go? Is delete called on it? What if someone else holds a pointer to it? Is this a memory leak? ...

Java container .contains question

Is there an easy way to check a container if it contains a value, not an object? This is the code I'd like to work: String[] i = {"One", "Two", "Three"}; if (Arrays.asList(i).contains("One")){ return true; } Is there a way to do this or will I have to loop through the array myself? ...