Solved

Using FirstThat function with list containers

Posted on 1997-07-01
4
270 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

759 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

22 Experts available now in Live!

Get 1:1 Help Now