All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ibm.icu.impl.CollectionSet Maven / Gradle / Ivy

Go to download

International Component for Unicode for Java (ICU4J) is a mature, widely used Java library providing Unicode and Globalization support

There is a newer version: 76.1
Show newest version
// © 2018 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html#License
package com.ibm.icu.impl;

import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

/**
 * A wrapper around java.util.Collection that implements java.util.Set. This class keeps a pointer to the
 * Collection and does not persist any data on its own.
 *
 * Useful when you need a Set but creating a HashSet is too expensive.
 *
 * IMPORTANT: The elements of the Collection *must* be unique! This class does not check.
 */
public class CollectionSet implements Set {

    private final Collection data;

    public CollectionSet(Collection data) {
        this.data = data;
    }

    @Override
    public int size() {
        return data.size();
    }

    @Override
    public boolean isEmpty() {
        return data.isEmpty();
    }

    @Override
    public boolean contains(Object o) {
        return data.contains(o);
    }

    @Override
    public Iterator iterator() {
        return data.iterator();
    }

    @Override
    public Object[] toArray() {
        return data.toArray();
    }

    @Override
    public  T[] toArray(T[] a) {
        return data.toArray(a);
    }

    @Override
    public boolean add(E e) {
        return data.add(e);
    }

    @Override
    public boolean remove(Object o) {
        return data.remove(o);
    }

    @Override
    public boolean containsAll(Collection c) {
        return data.containsAll(c);
    }

    @Override
    public boolean addAll(Collection c) {
        return data.addAll(c);
    }

    @Override
    public boolean retainAll(Collection c) {
        return data.retainAll(c);
    }

    @Override
    public boolean removeAll(Collection c) {
        return data.removeAll(c);
    }

    @Override
    public void clear() {
        data.clear();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy