• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

Using FirstThat function with list containers

Has anyone any example clue about using the FirstThat function with a list container such as TSListImp on Borland C++.
0
sagitarian
Asked:
sagitarian
  • 2
  • 2
1 Solution
 
md041797Commented:
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
 
sagitarianAuthor Commented:
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
 
md041797Commented:
Yes, that's the intent.  It allows the object to do it's own testing.
0
 
sagitarianAuthor Commented:
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now