-- This file is part of the 'union-find-array' library. It is licensed
-- under an MIT license. See the accompanying 'LICENSE' file for details.
--
-- Authors: Bertram Felgenhauer

{-# LANGUAGE GeneralizedNewtypeDeriving #-}

module Data.Union.Type (
    Union (..),
    Node (..),
) where

import Data.Array.Unboxed
import Data.Array

-- | An immutable disjoint set forest.
data Union a = Union {
    Union a -> Int
size  :: !Int,
    Union a -> UArray Int Int
up    :: UArray Int Int,
    Union a -> Array Int a
label :: Array Int a
}

-- | A node in a disjoint set forest.
newtype Node = Node { Node -> Int
fromNode :: Int }
    deriving (Node -> Node -> Bool
(Node -> Node -> Bool) -> (Node -> Node -> Bool) -> Eq Node
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Node -> Node -> Bool
$c/= :: Node -> Node -> Bool
== :: Node -> Node -> Bool
$c== :: Node -> Node -> Bool
Eq, Eq Node
Eq Node
-> (Node -> Node -> Ordering)
-> (Node -> Node -> Bool)
-> (Node -> Node -> Bool)
-> (Node -> Node -> Bool)
-> (Node -> Node -> Bool)
-> (Node -> Node -> Node)
-> (Node -> Node -> Node)
-> Ord Node
Node -> Node -> Bool
Node -> Node -> Ordering
Node -> Node -> Node
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Node -> Node -> Node
$cmin :: Node -> Node -> Node
max :: Node -> Node -> Node
$cmax :: Node -> Node -> Node
>= :: Node -> Node -> Bool
$c>= :: Node -> Node -> Bool
> :: Node -> Node -> Bool
$c> :: Node -> Node -> Bool
<= :: Node -> Node -> Bool
$c<= :: Node -> Node -> Bool
< :: Node -> Node -> Bool
$c< :: Node -> Node -> Bool
compare :: Node -> Node -> Ordering
$ccompare :: Node -> Node -> Ordering
$cp1Ord :: Eq Node
Ord, Ord Node
Ord Node
-> ((Node, Node) -> [Node])
-> ((Node, Node) -> Node -> Int)
-> ((Node, Node) -> Node -> Int)
-> ((Node, Node) -> Node -> Bool)
-> ((Node, Node) -> Int)
-> ((Node, Node) -> Int)
-> Ix Node
(Node, Node) -> Int
(Node, Node) -> [Node]
(Node, Node) -> Node -> Bool
(Node, Node) -> Node -> Int
forall a.
Ord a
-> ((a, a) -> [a])
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> Int)
-> ((a, a) -> Int)
-> Ix a
unsafeRangeSize :: (Node, Node) -> Int
$cunsafeRangeSize :: (Node, Node) -> Int
rangeSize :: (Node, Node) -> Int
$crangeSize :: (Node, Node) -> Int
inRange :: (Node, Node) -> Node -> Bool
$cinRange :: (Node, Node) -> Node -> Bool
unsafeIndex :: (Node, Node) -> Node -> Int
$cunsafeIndex :: (Node, Node) -> Node -> Int
index :: (Node, Node) -> Node -> Int
$cindex :: (Node, Node) -> Node -> Int
range :: (Node, Node) -> [Node]
$crange :: (Node, Node) -> [Node]
$cp1Ix :: Ord Node
Ix)