Commit Graph

21 Commits

Author SHA1 Message Date
Julien Fischer
66fd7c19e5 Library documentation fix.
library/psqueue.m:
    s/provide/provides/ in a sport.
2022-07-26 12:10:37 +10:00
Julien Fischer
31d5a2bef9 Fix typos in library documentation.
library/integer.m:
library/psqueue.m:
library/string.m:
    s/This modules/This module/
2022-07-25 00:52:24 +10:00
Zoltan Somogyi
06f81f1cf0 Add end_module declarations ...
.. to modules which did not yet have them.
2022-01-09 10:36:15 +11:00
Zoltan Somogyi
0d7c8a7654 Specify pred or func for all pragmas.
*/*.m:
    As above.

configure.ac:
    Require the installed compiler to support this capability.
2021-06-16 15:23:58 +10:00
Zoltan Somogyi
95f8f56716 Delete unneeded $module args from calls to expect/unexpected. 2019-07-03 22:37:19 +02:00
Julien Fischer
36a35897e3 Delete a doubled-up word.
library/psqueue.m:
    As above.
2019-07-01 14:57:43 +10:00
Mark Brown
d465fa53cb Update the COPYING.LIB file and references to it.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.

COPYING.LIB:
    Add a special linking exception to the LGPL.

*:
    Update references to COPYING.LIB.

    Clean up some minor errors that have accumulated in copyright
    messages.
2018-06-09 17:43:12 +10:00
Peter Wang
4af0c874af Clarify meaning of "abort" in library documentation.
library/assoc_list.m:
library/bag.m:
library/bimap.m:
library/calendar.m:
library/char.m:
library/digraph.m:
library/list.m:
library/map.m:
library/multi_map.m:
library/psqueue.m:
library/rbtree.m:
library/string.m:
library/term.m:
library/tree234.m:
library/type_desc.m:
library/univ.m:
library/varset.m:
    Replace most occurrences of "abort" with "throw an exception".

    Slightly improve the documentation for map.search, map.lookup,
    map.inverse_search.

library/deconstruct.m:
    Replace "abort" with "runtime abort" where that is meant.
2017-10-09 21:48:29 +11:00
Zoltan Somogyi
c3e089c401 Wrap overlong lines. 2017-01-12 04:32:30 +11:00
Zoltan Somogyi
5057ab7e04 Use explicit streams in some library modules.
library/backjump.m:
library/exception.m:
library/getopt_io.m:
library/psqueue.m:
library/set_ctree234.m:
library/set_tree234.m:
library/tree234.m:
    Avoid using implicit streams.

library/io.m:
    Add a version of the write_cc predicate that allows callers
    to specify an explicit stream.

    Fix what seems like an old bug in read_binary_file_as_bitmap: it was not
    reading from the file at all.

    Use explicit module qualification in some places to make the code more
    readable.

library/table_statistics.m:
    Add a version of the write_table_stats predicate that allows callers
    to specify an explicit stream.

    Avoid using implicit streams inside the module as well.

library/term_io.m:
    Add versions of the predicates that read terms that allow callers
    to specify an explicit stream.

    Avoid using implicit streams inside the module as well.

library/parser.m:
    Add module qualifications that are needed after the new addition of new
    predicates to term_io.m.

library/stream.m:
library/stream.string_writer.m:
    Fix style.
2016-10-30 00:49:21 +11:00
Zoltan Somogyi
701ed0de9a Delete unused predicates. 2015-12-12 16:03:50 +11:00
Zoltan Somogyi
f0ffbbc13c Convert (C->T;E) to (if C then T else E). 2015-12-01 05:35:29 +11:00
Julien Fischer
8a7fc55ed4 Fix spelling in psqueue module.
library/psqueue.m:
	As above.
2015-01-14 13:54:00 +11:00
Zoltan Somogyi
50fe9c7fd0 Remove trace code accidentally left in. 2014-12-12 18:16:12 +11:00
Zoltan Somogyi
6b9afbdd9f Significantly improve psqueue.m.
library/psqueue.m:
    Fix a bug: the adjust predicate was documented to fail if asked to adjust
    the priority of a nonexistent key, but it succeeded anyway.

    Fix a bug: the function that computed the size of a psqueue did not count
    the priority/key pair in the winner structure.

    Make the at_most predicate significantly more efficient, by eliminating
    an expensive conversion to the min view. Most of the contents of the min
    view was not needed. In Haskell (the language used in the paper that
    this module is derived from), computing stuff that won't be looked at
    is cheap due to lazyness; in Mercury, it can be expensive.

    Make the at_most predicate significantly more efficient in another respect
    as well, by using cords to avoid re-re-re-appending the same elements.

    Make most other predicates more efficient by eliminating the redundant
    checking for empty queues. For example, when you convert a nonempty queue
    to the tournament view, you shouldn't need to check whether the result
    is a tournament with no players; it will not be. This change required
    two main changes in data structures. The first is to separate out
    the concepts of psqueues that may be empty from those which may not.
    The second is updating the tournament view to eliminate the possibility
    of no players, and handling empty psqueues *without* converting them
    to the tournament view.

    Document the meanings of the module's data structures, both original
    and updated, including their invariants (at least, the invariants
    I can see).

    Delete the type for min views, since after the performance fix to at_most,
    it is no longer needed.

    Delete the type for tree views, since it is isomorphic to the actual
    data structure, and conversions to it just waste time.

    Delete the t_ prefix from the names of types.

    Change the documentation of predicates to use full sentences, not just
    sentence fragments.

    Do not include the predicates intended only for unit tests in the
    publicly documented part of the interface.

    Use the P, K order of type variables CONSISTENTLY. Change the order
    of fields representing priority/key pairs in structures likewise.

    Use consistent naming schemes for variables: PSQx for psqueues, LTreex
    for ltrees, etc. Use xPrime instead of x0 for variables bound in the
    conditions of if-then-elses. Use Maybe as a prefix on the names of
    variables of maybe types.

    Avoid the use of generic variable names such as "Res"; use names that
    reflect the value being returned instead.

    Avoid the use of numeric suffixes on variables when these do NOT denote
    progression over time; use A and B, or L and R, suffixes instead.

    Give some function symbols and predicates more meaningful names.

    Internal operations do not need to be available as both functions
    and predicates; pick whichever seems more appropriate, and remove
    the other. Remove some other unused functions, such as construct_leaf.

    Factor out some common code, e.g. for updating minimums and maximums.

    Remove redundant "is det" declarations from functions.

    Fix the type specializations. Specializing a predicate is useless
    unless its caller either always calls it with values of the specialized
    type, or is itself specialized the same way. This module needs the latter,
    so add type specializations to all predicates between the exported
    predicates and the primitives that can directly benefit from the
    specializations.

tests/hard_coded/psqueue_test.{m,exp}:
    Make this test case significantly harder. The old version did not
    pick up the two bugs referred to above, but the new version does.
2014-12-12 17:42:39 +11:00
Julien Fischer
9daeb1770f Fix a typo.
library/psqueue.m:
	As above.
2014-12-12 09:24:34 +11:00
Julien Fischer
0ff7bee16b Fix spelling in psqueue module.
library/psqueue.m:
	As above.
2014-12-12 09:23:13 +11:00
Paul Bone
4700b73596 Update psqueue.m's interface to match other library modules.
library/psqueue.m:
    Make the psqueue interface more consistent with other standard library
    modules.

tests/hard_coded/psqueue_test.exp:
tests/hard_coded/psqueue_test.m:
    Update tests.
2014-12-07 23:15:28 +11:00
Paul Bone
8df5533ed5 Update psqueue.m code style.
library/psqueue.m:
    Update coding style.

    In min_view/1 there's two variable names are incorrect (they should be
    swapped) this doesn't change the program but may confuse people reading
    the code.

tests/hard_coded/psqueue_test.exp:
tests/hard_coded/psqueue_test.m:
    Also improve the coding style in the test code.
    Add lables to all of the test outputs.
2014-12-07 23:14:35 +11:00
Paul Bone
9658121e52 Update psqueue documentation.
library/psqueue.m:
    As atove.
2014-12-07 21:54:07 +11:00
Matthias Güdemann
02c6c4f155 Add priority search queue ADT
This implements a priority search queue ADT. This is a kind of blend
between priority queues and search trees; in contrast to a priority
queue, it also allows changing priorities of keys, looking up keys and
deleting keys.

This is an implementation based on the ICFP 2001 paper "A Simple
Implementation Technique for Priority Search Queues" by Ralf Hinze.
http://www.mercurylang.org/list-archives/users/2014-October/007804.html

Commit message paraphrased from Matthias' e-mail.
http://www.mercurylang.org/list-archives/reviews/2014-October/017414.html

library/psqueue.m:
    Add new module.

library/MODULES_DOC:
library/library.m:
    Include new module.

tests/hard_coded/Mmakefile:
tests/hard_coded/psqueue_test.exp:
tests/hard_coded/psqueue_test.m:
    Add test for psqueue.m
2014-12-07 21:54:07 +11:00