x = new ArrayList<>(new LinkedHashSet<>(x));
x = new ArrayList<T>(new HashSet<T>(x));
final HashSet<T> seen = new HashSet<T>();
final Iterator<T> listIt = x.iterator();
while (listIt.hasNext()) {
final T curr = listIt.next();
if (seen.contains(curr)) {
listIt.remove();
} else {
seen.add(curr);
}
}
Iterator<T> g;
T t;
int i, n;
for (i = 0, n = x.size(); i < n; ++i) {
t = x.get(i);
g = x.listIterator(i + 1);
while (g.hasNext())
if (g.next().equals(t)) {
g.remove();
--n;
}
}
Set<T> uniques = new HashSet<>(x);
x.clear();
x.addAll(uniques);
std::vector<std::string> x = {"one", "two", "two", "one", "three"};
std::unordered_set<std::string> t;
for (auto e : x)
t.insert(e);
std::sort(x.begin(), x.end());
auto last = std::unique(x.begin(), x.end());
x.erase(last, x.end());
var uniques = x.Distinct().ToList();
x = redBlackTree(x)[].array;
func deduplicate[S ~[]T, T comparable](x S) S {
seen := make(map[T]bool)
j := 0
for _, v := range x {
if !seen[v] {
x[j] = v
j++
seen[v] = true
}
}
var zero T
for i := j; i < len(x); i++ {
// Avoid memory leak
x[i] = zero
}
return x[:j]
}
seen := make(map[T]bool)
j := 0
for _, v := range x {
if !seen[v] {
x[j] = v
j++
seen[v] = true
}
}
for i := j; i < len(x); i++ {
x[i] = nil
}
x = x[:j]
seen := make(map[T]bool)
j := 0
for _, v := range x {
if !seen[v] {
x[j] = v
j++
seen[v] = true
}
}
x = x[:j]
slices.Sort(x)
x = slices.Compact(x)
y := make(map[T]struct{}, len(x))
for _, v := range x {
y[v] = struct{}{}
}
x2 := make([]T, 0, len(y))
for _, v := range x {
if _, ok := y[v]; ok {
x2 = append(x2, v)
delete(y, v)
}
}
x = x2
const seen = new Set();
x = x.filter( v => {
if(seen.has(v))
return false;
seen.add(v);
return true;
});
x = Array.from(new Set(x));
local seen = {}
for index,item in ipairs(x) do
if seen[item] then
table.remove(x, index)
else
seen[item] = true
end
end
[NSSet setWithArray:x].allObjects
var
x: TList;
begin
for i:= x.count-1 downto 0 do
if x.indexOf(x.items[i]) <> -1 then
x.delete(i);
end;
def dedup(x):
y = []
for i in x:
if not i in y:
y.append(i)
return y
x = list(OrderedDict(zip(x, x)))
let dedup: Vec<_> = x.iter().unique().collect();
(define (remove-duplicates l)
(cond ((null? l)
'())
((member (car l) (cdr l))
(remove-duplicates (cdr l)))
(else
(cons (car l) (remove-duplicates (cdr l))))))
(remove-duplicates x)