Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /smlnj-lib/branches/rt-transition/Util/splay-map-fn.sml
ViewVC logotype

Diff of /smlnj-lib/branches/rt-transition/Util/splay-map-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2980, Sat Apr 12 15:01:15 2008 UTC revision 4070, Thu Jun 11 12:33:25 2015 UTC
# Line 1  Line 1 
1  (* splay-map-fn.sml  (* splay-map-fn.sml
2   *   *
3     * COPYRIGHT (c) 2012 The Fellowship of SML/NJ (http://www.smlnj.org)
4     * All rights reserved.
5     *
6   * COPYRIGHT (c) 1993 by AT&T Bell Laboratories.  See COPYRIGHT file for details.   * COPYRIGHT (c) 1993 by AT&T Bell Laboratories.  See COPYRIGHT file for details.
7   *   *
8   * Functor implementing dictionaries using splay trees.   * Functor implementing dictionaries using splay trees.
# Line 388  Line 391 
391              foldli f empty m              foldli f empty m
392            end            end
393    
394      (* check the elements of a map with a predicate and return true if
395       * any element satisfies the predicate. Return false otherwise.
396       * Elements are checked in key order.
397       *)
398        fun exists pred = let
399              fun exists' SplayNil = false
400                | exists' (SplayObj{value=(_, x), left, right}) =
401                    exists' left orelse pred x orelse exists' right
402              in
403                fn EMPTY => false | (MAP{root, ...}) => exists' (!root)
404              end
405        fun existsi pred = let
406              fun exists' SplayNil = false
407                | exists' (SplayObj{value, left, right}) =
408                    exists' left orelse pred value orelse exists' right
409              in
410                fn EMPTY => false | (MAP{root, ...}) => exists' (!root)
411              end
412    
413      (* check the elements of a map with a predicate and return true if
414       * they all satisfy the predicate. Return false otherwise.  Elements
415       * are checked in key order.
416       *)
417        fun all pred = let
418              fun all' SplayNil = true
419                | all' (SplayObj{value=(_, x), left, right}) =
420                    all' left andalso pred x andalso all' right
421              in
422                fn EMPTY => true | (MAP{root, ...}) => all' (!root)
423              end
424        fun alli pred = let
425              fun all' SplayNil = true
426                | all' (SplayObj{value, left, right}) = all' left andalso pred value andalso all' right
427              in
428                fn EMPTY => true | (MAP{root, ...}) => all' (!root)
429              end
430    
431    end (* SplayDictFn *)    end (* SplayDictFn *)

Legend:
Removed from v.2980  
changed lines
  Added in v.4070

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0