]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/interval-sets/interval-sets.factor
factor: trim using lists
[factor.git] / basis / interval-sets / interval-sets.factor
index 32b671d212c577f75a151c2d5f33462549635a41..b444ad7e6d355261fddd28b4f732caa44caf719d 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2009 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types arrays assocs binary-search
-combinators fry grouping kernel locals make math math.order
-sequences sequences.private sorting specialized-arrays ;
+classes combinators grouping kernel locals make math
+math.order sequences sequences.private sorting
+specialized-arrays ;
 SPECIALIZED-ARRAY: uint
 IN: interval-sets
 ! Sets of positive integers
@@ -10,17 +11,8 @@ IN: interval-sets
 ! Intervals are a pair of { start end }
 TUPLE: interval-set { array uint-array read-only } ;
 
-<PRIVATE
-
-ERROR: not-an-interval-set obj ;
-
-: check-interval-set ( map -- map )
-    dup interval-set? [ not-an-interval-set ] unless ; inline
-
-PRIVATE>
-
-: in? ( key set -- ? )
-    check-interval-set array>>
+: interval-in? ( key set -- ? )
+    interval-set check-instance array>>
     dupd [ <=> ] with search swap [
         even? [ >= ] [ 1 - <= ] if
     ] [ 2drop f ] if* ;