0

I have a vector of a structure..

say

struct employee
{
string name;
int age;
int empId;
};

and a vector of this structure

RWTValOrderedVector<employee> vec;

suppose this vector has 4 entries. Now if i want to find in this vector for employee information of a specific employeeid, how do i do that without looping through the vector and fetching each structure and comparing the empId value of each structure with the i/p?

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by DangerDev
0

u make a hash table where empId will be key and it will return pointer to particular structure. this will make u'r job easy.

0

i'm not really sure how to do that.. will try and find out ... thanks a lot ...

0

make two dimension array say arr[m,2] , in first dimension u store all empId, like arr[n][0]=empid
and in second dim u store pointer to corresponding structure. like arr[n][1]=ptr , then write a function which returns pointer to structure and take empid,,,,

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.