Commit Graph

1 Commits

Author SHA1 Message Date
Zoltan Somogyi
90462e8c36 Improve bag.m.
library/bag.m:
    The old implementations of bag.subtract, bag.least_upper_bound,
    bag.union, bag.intersect iterated over their second bag arguments,
    and did a logarithmic amount of work in each iteration. This is good
    if the second bag is small, but not if it is big. Keep those
    implementations as the implementation of bag.subtract_small,
    bag.least_upper_bound_small etc, and replace the implementation
    of bag.subtract etc with code that iterates over the assoc_list version
    of both bags. This does work that linear in total size of the two sets.

    Replace the implementation of bag.subset_compare with one
    that actually works.

    Replace the implementation of bag.is_subbag with one that
    does significantly less work.

    Group related predicates together.

    Improve the documentation of the exported predicates.

    Use a more descriptive and more consistent set of variable names.

tests/hard_coded/test_bag.{m,exp}:
    A new test case, to test the new algorithms in bag.m.

tests/hard_coded/Mmakefile:
    Enable the new test case.
2015-09-02 05:57:46 +10:00