From d6dc6ef9112699c2950aaf4a04849c30b84ec4cc Mon Sep 17 00:00:00 2001
From: Liyang HU <git@liyang.hu>
Date: Tue, 7 Jun 2011 15:46:04 +0900
Subject: [PATCH 1/4] Moved data IntSet to Data.IntSet.Internal
---
Data/IntSet.hs | 21 ++-------------------
Data/IntSet/Internal.hs | 21 +++++++++++++++++++++
containers.cabal | 2 ++
3 files changed, 25 insertions(+), 19 deletions(-)
create mode 100644 Data/IntSet/Internal.hs
diff --git a/Data/IntSet.hs b/Data/IntSet.hs
index bcc5104..7c95324 100644
|
a
|
b
|
|
| 139 | 139 | import Data.Word |
| 140 | 140 | #endif |
| 141 | 141 | |
| | 142 | import Data.IntSet.Internal |
| | 143 | |
| 142 | 144 | infixl 9 \\{-This comment teaches CPP correct behaviour -} |
| 143 | 145 | |
| 144 | 146 | -- A "Nat" is a natural machine word (an unsigned Int) |
| … |
… |
|
| 171 | 173 | (\\) :: IntSet -> IntSet -> IntSet |
| 172 | 174 | m1 \\ m2 = difference m1 m2 |
| 173 | 175 | |
| 174 | | {-------------------------------------------------------------------- |
| 175 | | Types |
| 176 | | --------------------------------------------------------------------} |
| 177 | | -- | A set of integers. |
| 178 | | data IntSet = Nil |
| 179 | | | Tip {-# UNPACK #-} !Int |
| 180 | | | Bin {-# UNPACK #-} !Prefix {-# UNPACK #-} !Mask !IntSet !IntSet |
| 181 | | -- Invariant: Nil is never found as a child of Bin. |
| 182 | | -- Invariant: The Mask is a power of 2. It is the largest bit position at which |
| 183 | | -- two elements of the set differ. |
| 184 | | -- Invariant: Prefix is the common high-order bits that all elements share to |
| 185 | | -- the left of the Mask bit. |
| 186 | | -- Invariant: In Bin prefix mask left right, left consists of the elements that |
| 187 | | -- don't have the mask bit set; right is all the elements that do. |
| 188 | | |
| 189 | | |
| 190 | | type Prefix = Int |
| 191 | | type Mask = Int |
| 192 | | |
| 193 | 176 | instance Monoid IntSet where |
| 194 | 177 | mempty = empty |
| 195 | 178 | mappend = union |
diff --git a/Data/IntSet/Internal.hs b/Data/IntSet/Internal.hs
new file mode 100644
index 0000000..4fe16b9
|
a
|
b
|
|
| | 1 | module Data.IntSet.Internal {- export everything -} where |
| | 2 | |
| | 3 | {-------------------------------------------------------------------- |
| | 4 | Types |
| | 5 | --------------------------------------------------------------------} |
| | 6 | |
| | 7 | -- | A set of integers. |
| | 8 | data IntSet = Nil |
| | 9 | | Tip {-# UNPACK #-} !Int |
| | 10 | | Bin {-# UNPACK #-} !Prefix {-# UNPACK #-} !Mask !IntSet !IntSet |
| | 11 | -- Invariant: Nil is never found as a child of Bin. |
| | 12 | -- Invariant: The Mask is a power of 2. It is the largest bit position at which |
| | 13 | -- two elements of the set differ. |
| | 14 | -- Invariant: Prefix is the common high-order bits that all elements share to |
| | 15 | -- the left of the Mask bit. |
| | 16 | -- Invariant: In Bin prefix mask left right, left consists of the elements that |
| | 17 | -- don't have the mask bit set; right is all the elements that do. |
| | 18 | |
| | 19 | type Prefix = Int |
| | 20 | type Mask = Int |
| | 21 | |
diff --git a/containers.cabal b/containers.cabal
index 72d1a10..9d6abef 100644
|
a
|
b
|
|
| 29 | 29 | Data.IntSet |
| 30 | 30 | Data.Map |
| 31 | 31 | Data.Set |
| | 32 | other-modules: |
| | 33 | Data.IntSet.Internal |
| 32 | 34 | include-dirs: include |
| 33 | 35 | extensions: CPP |
| 34 | 36 | if !impl(nhc98) { |