/** Add (union) in a complete set. * @param other the set we are adding in. * @return true if this changes the set. */ public boolean add(symbol_set other) throws internal_error { boolean result = false; not_null(other); /* walk down the other set and do the adds individually */ for (Enumeration e = other.all(); e.hasMoreElements(); ) result = add((symbol)e.nextElement()) || result; return result; }
/** Determine if this set is an (improper) subset of another. * @param other the set we are testing against. */ public boolean is_subset_of(symbol_set other) throws internal_error { not_null(other); /* walk down our set and make sure every element is in the other */ for (Enumeration e = all(); e.hasMoreElements(); ) if (!other.contains((symbol)e.nextElement())) return false; /* they were all there */ return true; }
/** Generic equality comparison. */ public boolean equals(Object other) { if (!(other instanceof symbol_set)) return false; else return equals((symbol_set)other); }
/** Determine if this set is an (improper) superset of another. * @param other the set we are are testing against. */ public boolean is_superset_of(symbol_set other) throws internal_error { not_null(other); return other.is_subset_of(this); }
/** Remove (set subtract) a complete set. * @param other the set we are removing. */ public void remove(symbol_set other) throws internal_error { not_null(other); /* walk down the other set and do the removes individually */ for (Enumeration e = other.all(); e.hasMoreElements(); ) remove((symbol)e.nextElement()); }
outgoing = new symbol_set(); for (i = st.items().all(); i.hasMoreElements(); ) if (sym != null) outgoing.add(sym); for (s = outgoing.all(); s.hasMoreElements(); )
/** Equality comparison. */ public boolean equals(symbol_set other) { if (other == null || other.size() != size()) return false; /* once we know they are the same size, then improper subset does test */ try { return is_subset_of(other); } catch (internal_error e) { /* can't throw the error (because super class doesn't), so we crash */ e.crash(); return false; } }
/** Constructor for cloning from another set. * @param other the set we are cloning from. */ public symbol_set(symbol_set other) throws internal_error { not_null(other); _all = (Hashtable)other._all.clone(); }
/** Compute a hash code. */ public int hashCode() { int result = 0; int cnt; Enumeration e; /* hash together codes from at most first 5 elements */ for (e = all(), cnt=0 ; e.hasMoreElements() && cnt<5; cnt++) result ^= ((symbol)e.nextElement()).hashCode(); return result; }
/** Remove (set subtract) a complete set. * @param other the set we are removing. */ public void remove(symbol_set other) throws internal_error { not_null(other); /* walk down the other set and do the removes individually */ for (Enumeration e = other.all(); e.hasMoreElements(); ) remove((symbol)e.nextElement()); };
outgoing = new symbol_set(); for (i = st.items().all(); i.hasMoreElements(); ) if (sym != null) outgoing.add(sym); for (s = outgoing.all(); s.hasMoreElements(); )
/** Determine if this set is an (improper) superset of another. * @param other the set we are are testing against. */ public boolean is_superset_of(symbol_set other) throws internal_error { not_null(other); return other.is_subset_of(this); }
/** Equality comparison. */ public boolean equals(symbol_set other) { if (other == null || other.size() != size()) return false; /* once we know they are the same size, then improper subset does test */ try { return is_subset_of(other); } catch (internal_error e) { /* can't throw the error (because super class doesn't), so we crash */ e.crash(); return false; } }
/** Constructor for cloning from another set. * @param other the set we are cloning from. */ public symbol_set(symbol_set other) throws internal_error { not_null(other); _all = (Hashtable)other._all.clone(); }
/** Compute a hash code. */ public int hashCode() { int result = 0; int cnt; Enumeration e; /* hash together codes from at most first 5 elements */ for (e = all(), cnt=0 ; e.hasMoreElements() && cnt<5; cnt++) result ^= ((symbol)e.nextElement()).hashCode(); return result; }
/** Remove (set subtract) a complete set. * @param other the set we are removing. */ public void remove(symbol_set other) throws internal_error { not_null(other); /* walk down the other set and do the removes individually */ for (Enumeration e = other.all(); e.hasMoreElements(); ) remove((symbol)e.nextElement()); }
/** Determine if this set is an (improper) subset of another. * @param other the set we are testing against. */ public boolean is_subset_of(symbol_set other) throws internal_error { not_null(other); /* walk down our set and make sure every element is in the other */ for (Enumeration e = all(); e.hasMoreElements(); ) if (!other.contains((symbol)e.nextElement())) return false; /* they were all there */ return true; }
/** Add (union) in a complete set. * @param other the set we are adding in. * @return true if this changes the set. */ public boolean add(symbol_set other) throws internal_error { boolean result = false; not_null(other); /* walk down the other set and do the adds individually */ for (Enumeration e = other.all(); e.hasMoreElements(); ) result = add((symbol)e.nextElement()) || result; return result; }
outgoing = new symbol_set(); for (i = st.items().all(); i.hasMoreElements(); ) if (sym != null) outgoing.add(sym); for (s = outgoing.all(); s.hasMoreElements(); )
/** Determine if this set is an (improper) superset of another. * @param other the set we are are testing against. */ public boolean is_superset_of(symbol_set other) throws internal_error { not_null(other); return other.is_subset_of(this); }