public boolean IsSimilarTo(Cluster other, double overlapDegree) {
        assert(other != null);
        // ------------------------------------------------
        // Find the common documents. If there are only a few documents,
        // a linear search is used; otherwise the search uses a hash table.
        int common = 0;

        if((documents_.size() <= 3) &&
           (other.documents_.size() <= 3)) {
            // Few documents case, do a linear search.
            for(int i = 0; i < documents_.size(); i++) {
                Document doc = documents_.get(i);
                if(other.documents_.contains(doc)) {
                    common++;
                }
            }
        }
        else {
            // Many documents case, use a hash table.
            Hashtable<Document, Document> hash = new Hashtable<Document, Document>();
            int count = documents_.size();
            
            for(int i = 0; i < count; i++) {
                Document doc = documents_.get(i);
                hash.put(doc, doc);
            }

            // Check which of the documents from the other clusters
            // are found in the hash table.
            count = other.documents_.size();
            
            for(int i = 0; i < count; i++) {
                if(hash.containsKey(other.documents_.get(i))) {
                    common++;
                }
            }
        }

        return ((double)common / (double)documents_.size()) > overlapDegree &&
               ((double)common / (double)other.documents_.size()) > overlapDegree;
    }