Solved

Using FirstThat function with list containers

Posted on 1997-07-01
4
271 Views
Last Modified: 2006-11-17
Has anyone any example clue about using the FirstThat function with a list container such as TSListImp on Borland C++.
0
Comment
Question by:sagitarian
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
md041797 earned 70 total points
ID: 1164209
If memory serves:


int CondFunction (const obj &o, void *p) {
  o.testIt (p);
  }

int obj::testIt (void *p) {
  return *(int *)p == 5; // or whatever
  }

TSListImp <obj> list;
...
int testval = 4;
const obj &TheFirstItem = list.FirstThat (CondFunction, &testval);


0
 

Author Comment

by:sagitarian
ID: 1164210
Would just need an opinion on the global program construction.
Maybe, most of the time, the function 'CondFunction' is very specific to the function from which it is called.
Haven't seen yet a better way to arrange the program.
0
 
LVL 4

Expert Comment

by:md041797
ID: 1164211
Yes, that's the intent.  It allows the object to do it's own testing.
0
 

Author Comment

by:sagitarian
ID: 1164212
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now