Remove duplicate items in wxArrayInt

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Remove duplicate items in wxArrayInt

Post by dkaip »

Hello.
There is an easy way to remove duplicate items?
Thank you
Jim.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Remove duplicate items in wxArrayInt

Post by doublemax »

dkaip wrote: Wed Mar 29, 2023 7:05 pm There is an easy way to remove duplicate items?
If with "easy" you mean a single call that does this for you: No.

Are you forced to use wxArrayInt because it's used by a wxWidgets method? Or could you use another container?
Use the source, Luke!
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Remove duplicate items in wxArrayInt

Post by dkaip »

I am looking for an easy way with wxWidgets framework.
I is pretty for that great framework not have something.
Thank you.
Jim
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Remove duplicate items in wxArrayInt

Post by ONEEYEMAN »

Hi,
Why not use std::vector<> instead?

All those wx-related container are done because there was no STL when the library was created (in 1980th).

STL will mark all of them obsolete.

Unless you absolutely have to use them (for compatibility reasons with the 3rd party library).

Thank you.
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Remove duplicate items in wxArrayInt

Post by dkaip »

So i must use vector container.
Thank you
Jim.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Remove duplicate items in wxArrayInt

Post by doublemax »

dkaip wrote: Fri Mar 31, 2023 5:28 am So i must use vector container.
std::vector doesn't have a function for that either. The best solution depends on your use case which you still haven't told us.

Look into std::set and std::unordered_set
https://www.programiz.com/cpp-programming/unordered-set
Use the source, Luke!
Post Reply