package org.academiadecodigo.enuminatti.uniqueworld;

import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * MIT License
 * (c) 2017 Ricardo Constantino
 */

public class UniqueWord implements Iterable<String> {

    private Set<String> uniqueWords;

    public UniqueWord() {
        uniqueWords = new HashSet<>();
    }

    public void add(String wholeString) {
        Collections.addAll(uniqueWords, wholeString.split(" "));
    }

    public int size() {
        return uniqueWords.size();
    }

    @Override
    public Iterator<String> iterator() {
        return uniqueWords.iterator();
    }
}
