473,387 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

get a member of each element in an STL container

Is there a way to build a seperate array of objects, when those objects are
members of other objects, which are contained in a STL data structure?
, without iterating through the whole list one by one and getting them
seperatlely.
class A
{
public:
int * m_data;
};

typdef list<AMyList;
MyList g_mylist;

void Foo()
{
// for each A object I need the data member
int ** datalist = ??
}
Apr 10 '07 #1
1 1231
Christopher Pisz wrote:
Is there a way to build a seperate array of objects, when those
objects are members of other objects, which are contained in a STL
data structure? , without iterating through the whole list one by one
and getting them seperatlely.
class A
{
public:
int * m_data;
};

typdef list<AMyList;
MyList g_mylist;

void Foo()
{
// for each A object I need the data member
int ** datalist = ??
}
No, there is no way to do that without iterating through the whole
list. However, you could avoid iterating yourself if you write
a particular _functor_ and then use 'std::for_each'. Of course it
only means you're hiding the actual iteration behind the call to
'for_each' (and internally it does iterate through the range of
iterators you pass in), but it might be what you're asking about.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Apr 11 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Sat | last post by:
Hi, I have a simplified version of a problem that I am facing (hope I haven't oversimplified it). This code doesn't work now and I want to find how I can make it work. Can I call the derived...
1
by: Dave | last post by:
In Exceptional C++, the following code snippet appears at the bottom of page 197: template<class T> class Array : private ArrayBase, public Container { typedef Array AIType; public: Array(...
3
by: jut_bit_zx | last post by:
class A { public: A(); virtual ~A(){} .... private: int m_iarray; }
10
by: Adam Warner | last post by:
Hi all, With this structure that records the length of an array of pointers as its first member: struct array { ptrdiff_t length; void *ptr; };
1
by: Zenobia | last post by:
How do I bind an array, arrayList or even a stack to a repeater containing hyperlinks. The data structure (array, arrayList or even a stack) has dates in ISO format "YYYY-MM-DD". The repeated...
11
by: eeykay | last post by:
Hello, I am facing a starnge problem while erasing the last member in a vector. I am using VC++ .NET 2002 complier. I have vector of CComPtr<..> (irrelevant here), and then I iterate over the...
2
by: Carlos Rodriguez | last post by:
I have the following function in C#public void Undo(IDesignerHost host) { if (!this.componentName.Equals(string.Empty) && (this.member != null)) { IContainer container1 = (IContainer)...
2
by: Arnaud Delobelle | last post by:
Hi all, I often find myself needing to get (non-destructively) the value of the member of a singleton set. Is there a good way to do this (as an expression?) None of the ones I can think of...
0
by: removeps-groups | last post by:
Now I'm wondering how to display 3 elements next to each other. I came up with the following solution using float:left, but would like opinions if this is the right way to go. The idea is to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.