pike.git / lib / modules / ADT.pmod / Set.pike

version» Context lines:

pike.git/lib/modules/ADT.pmod/Set.pike:106:    result->add(item);       return this;   }         /////////////////   /// OPERATORS ///   /////////////////    -  +    //! Subset. A <= B returns true if all items in A are also present in B.   int(0..1) subset(ADT.Set other)   {    foreach(indices(set), mixed item)    if (!other->contains(item))    return 0;       return 1;   }    -  +    //! Superset. A >= B returns true if all items in B are also present in A.   int(0..1) superset(ADT.Set other)   {    return other <= this;   }         //! Equality. A == B returns true if all items in A are present in B,   //! and all items in B are present in A. Otherwise, it returns false.   int(0..1) `==(ADT.Set other)
pike.git/lib/modules/ADT.pmod/Set.pike:162:   //! True superset. A > B returns true if each item in B is also present   //! in A, and A contains at least one item not present in B.   int(0..1) `>(ADT.Set other)   {    if (sizeof(this) <= sizeof(other))    return 0;       return superset(other);   }    -  - //! Subset operator. - function `<= = subset; -  -  - //! Superset operator. - function `>= = superset; -  -  - //! Inequality. A != B is equivalent to !(A == B). - int(0..1) `!=(ADT.Set other) - { -  return !(this == other); - } -  -  +    //! Union. Returns a set containing all elements present in either   //! or both of the operand sets.   this_program `|(ADT.Set other)   {    ADT.Set result = ADT.Set(this);       foreach(indices(other), mixed item)    result->add(item);       return result;
pike.git/lib/modules/ADT.pmod/Set.pike:255:   //! is probably rather useless for sets, since the result is an array   //! which just contain 1's, one for each member of the set. Still,   //! this function is provided for consistency.   array(mixed) _values()   {    return values(set);   }         //! An ADT.Set can be cast to an array or a multiset. - mixed cast(string to) + protected mixed cast(string to)   {    switch(to)    { -  case "object": -  return this; -  +     case "array":    return indices(set);       case "multiset":    return copy_value(set);       default: -  error("Cannot cast ADT.Set to %s.\n", to); +  return UNDEFINED;    }   }         //! Number of items in the set.   int _sizeof()   {    return sizeof(set);   }