Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compare string content in 2 vectors

 
Vince Hon
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 vectors with the same elements:
vector1 { ID, name, phone }
vector2 { ID, name, phone }
and 1 vector which conisists of both elementS from vector1 and vector2
vector3 {ID1, ID2, name, phone1, phone2}
I want to find if the element "name" in these vector1 and vector2 are equal
i.e.
if vector 1 contain an element:
ID[1], name[Grace], phone[12345]
and vector 2 also contain an element:
ID[4], name[Grace], phone[99999]
I will add a new element in vector3, i.e.
ID[1], ID[2], name[Grace], phone[12345], phone[99999].
Are there any function in vector can do these in an more effiecient way ?
Thanks
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
retainAll()?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic