Vowpal Wabbit
Functions
stable_unique.h File Reference
#include <set>

Go to the source code of this file.

Functions

template<typename ForwardIterator >
ForwardIterator stable_unique (ForwardIterator begin, ForwardIterator end)
 

Function Documentation

◆ stable_unique()

template<typename ForwardIterator >
ForwardIterator stable_unique ( ForwardIterator  begin,
ForwardIterator  end 
)

Definition at line 9 of file stable_unique.h.

10 {
11  using value_t = typename std::iterator_traits<ForwardIterator>::value_type;
12 
13  std::set<value_t> unique_set;
14 
15  auto current_head = begin;
16  for (auto current_check = begin; current_check != end; current_check++)
17  {
18  if (unique_set.find(*current_check) == unique_set.end())
19  {
20  unique_set.insert(*current_check);
21  *current_head = *current_check;
22  current_head++;
23  }
24  }
25 
26  return current_head;
27 }