/**
  * Compares this set with another set for equality of their stored entries.
  *
  * @param other an <code>Object</code> value
  * @return true if the sets are identical
  */
 @Override
 public boolean equals(Object other) {
   if (_set.equals(other)) {
     return true; // comparing two trove sets
   } else if (other instanceof Set) {
     Set<?> that = (Set<?>) other;
     if (that.size() != _set.size()) {
       return false; // different sizes, no need to compare
     } else { // now we have to do it the hard way
       Iterator<?> it = that.iterator();
       for (int i = that.size(); i-- > 0; ) {
         Object val = it.next();
         if (val instanceof Long) {
           long v = ((Long) val).longValue();
           if (_set.contains(v)) {
             // match, ok to continue
           } else {
             return false; // no match: we're done
           }
         } else {
           return false; // different type in other set
         }
       }
       return true; // all entries match
     }
   } else {
     return false;
   }
 }
  public List<Group> buildGroupsDirected() {
    List<Group> groups = new LinkedList<>();

    // First determine 'start' relations, i.e. relations without incoming
    // edges in the relation graph
    TLongSet starts = new TLongHashSet();
    Collection<Long> ids = graph.getNodes();
    for (long id : ids) {
      if (graph.getEdgesIn(id).isEmpty()) {
        starts.add(id);
      }
    }
    // Build sub-graphs reachable from 'start' relations
    logger.debug("Number of start relations: " + starts.size());
    for (long start : starts.toArray()) {
      groups.add(build(start));
    }

    // In case of circles within the relation graph that are not reachable
    // from any start relation, there may be some relations left, that have
    // not been put into groups yet.
    TLongSet remaining = new TLongHashSet();
    remaining.addAll(ids);
    for (Group group : groups) {
      remaining.removeAll(group.getRelationIds());
    }
    if (remaining.size() > 0) {
      logger.debug("remaining: " + remaining.size());
      while (!remaining.isEmpty()) {
        long id = any(remaining);

        TLongSet reachable = reachable(graph, id);
        remaining.removeAll(reachable);

        long lowest = IdUtil.lowestId(reachable);
        groups.add(new Group(lowest, reachable));
      }
    }

    return groups;
  }
 @Override
 public boolean equals(Object other) {
   if (!(other instanceof TLongSet)) {
     return false;
   }
   final TLongSet that = (TLongSet) other;
   if (that.size() != this.size()) {
     return false;
   }
   for (int i = _states.length; i-- > 0; ) {
     if (_states[i] == FULL) {
       if (!that.contains(_set[i])) {
         return false;
       }
     }
   }
   return true;
 }