{-# LANGUAGE Trustworthy, MagicHash, MultiParamTypeClasses, FlexibleInstances #-}
module SDP.Vector
(
module SDP.Indexed,
module SDP.Sort,
module SDP.Scan,
Vector
)
where
import Prelude ()
import SDP.SafePrelude
import SDP.IndexedM
import SDP.Indexed
import SDP.Sort
import SDP.Scan
import qualified Data.Vector.Fusion.Bundle as B
import qualified Data.Vector as V
import Data.Vector.Generic ( stream )
import Data.Vector ( Vector )
import SDP.Unrolled.STUnlist
import SDP.Unrolled.IOUnlist
import SDP.Prim.SArray
import SDP.SortM.Tim
default ()
instance Nullable (Vector e)
where
isNull :: Vector e -> Bool
isNull = Vector e -> Bool
forall e. Vector e -> Bool
V.null
lzero :: Vector e
lzero = Vector e
forall e. Vector e
V.empty
instance Zip Vector
where
all6 :: (a -> b -> c -> d -> e -> f -> Bool)
-> Vector a
-> Vector b
-> Vector c
-> Vector d
-> Vector e
-> Vector f
-> Bool
all6 a -> b -> c -> d -> e -> f -> Bool
f Vector a
as Vector b
bs Vector c
cs Vector d
ds Vector e
es Vector f
fs = Bundle Vector Bool -> Bool
forall (v :: * -> *). Bundle v Bool -> Bool
B.and (Bundle Vector Bool -> Bool) -> Bundle Vector Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> d -> e -> f -> Bool)
-> Bundle Vector a
-> Bundle Vector b
-> Bundle Vector c
-> Bundle Vector d
-> Bundle Vector e
-> Bundle Vector f
-> Bundle Vector Bool
forall a b c d e f g (v :: * -> *).
(a -> b -> c -> d -> e -> f -> g)
-> Bundle v a
-> Bundle v b
-> Bundle v c
-> Bundle v d
-> Bundle v e
-> Bundle v f
-> Bundle v g
B.zipWith6 a -> b -> c -> d -> e -> f -> Bool
f
(Vector a -> Bundle Vector a
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector a
as) (Vector b -> Bundle Vector b
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector b
bs) (Vector c -> Bundle Vector c
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector c
cs) (Vector d -> Bundle Vector d
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector d
ds) (Vector e -> Bundle Vector e
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector e
es) (Vector f -> Bundle Vector f
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector f
fs)
all5 :: (a -> b -> c -> d -> e -> Bool)
-> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Bool
all5 a -> b -> c -> d -> e -> Bool
f Vector a
as Vector b
bs Vector c
cs Vector d
ds Vector e
es = Bundle Vector Bool -> Bool
forall (v :: * -> *). Bundle v Bool -> Bool
B.and (Bundle Vector Bool -> Bool) -> Bundle Vector Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> d -> e -> Bool)
-> Bundle Vector a
-> Bundle Vector b
-> Bundle Vector c
-> Bundle Vector d
-> Bundle Vector e
-> Bundle Vector Bool
forall a b c d e f (v :: * -> *).
(a -> b -> c -> d -> e -> f)
-> Bundle v a
-> Bundle v b
-> Bundle v c
-> Bundle v d
-> Bundle v e
-> Bundle v f
B.zipWith5 a -> b -> c -> d -> e -> Bool
f
(Vector a -> Bundle Vector a
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector a
as) (Vector b -> Bundle Vector b
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector b
bs) (Vector c -> Bundle Vector c
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector c
cs) (Vector d -> Bundle Vector d
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector d
ds) (Vector e -> Bundle Vector e
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector e
es)
all4 :: (a -> b -> c -> d -> Bool)
-> Vector a -> Vector b -> Vector c -> Vector d -> Bool
all4 a -> b -> c -> d -> Bool
f Vector a
as Vector b
bs Vector c
cs Vector d
ds = Bundle Vector Bool -> Bool
forall (v :: * -> *). Bundle v Bool -> Bool
B.and (Bundle Vector Bool -> Bool) -> Bundle Vector Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> d -> Bool)
-> Bundle Vector a
-> Bundle Vector b
-> Bundle Vector c
-> Bundle Vector d
-> Bundle Vector Bool
forall a b c d e (v :: * -> *).
(a -> b -> c -> d -> e)
-> Bundle v a
-> Bundle v b
-> Bundle v c
-> Bundle v d
-> Bundle v e
B.zipWith4 a -> b -> c -> d -> Bool
f
(Vector a -> Bundle Vector a
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector a
as) (Vector b -> Bundle Vector b
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector b
bs) (Vector c -> Bundle Vector c
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector c
cs) (Vector d -> Bundle Vector d
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector d
ds)
all3 :: (a -> b -> c -> Bool) -> Vector a -> Vector b -> Vector c -> Bool
all3 a -> b -> c -> Bool
f Vector a
as Vector b
bs Vector c
cs = Bundle Vector Bool -> Bool
forall (v :: * -> *). Bundle v Bool -> Bool
B.and (Bundle Vector Bool -> Bool) -> Bundle Vector Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> Bool)
-> Bundle Vector a
-> Bundle Vector b
-> Bundle Vector c
-> Bundle Vector Bool
forall a b c d (v :: * -> *).
(a -> b -> c -> d)
-> Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d
B.zipWith3 a -> b -> c -> Bool
f
(Vector a -> Bundle Vector a
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector a
as) (Vector b -> Bundle Vector b
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector b
bs) (Vector c -> Bundle Vector c
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector c
cs)
all2 :: (a -> b -> Bool) -> Vector a -> Vector b -> Bool
all2 a -> b -> Bool
f Vector a
as Vector b
bs = Bundle Vector Bool -> Bool
forall (v :: * -> *). Bundle v Bool -> Bool
B.and (Bundle Vector Bool -> Bool) -> Bundle Vector Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (a -> b -> Bool)
-> Bundle Vector a -> Bundle Vector b -> Bundle Vector Bool
forall a b c (v :: * -> *).
(a -> b -> c) -> Bundle v a -> Bundle v b -> Bundle v c
B.zipWith a -> b -> Bool
f
(Vector a -> Bundle Vector a
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector a
as) (Vector b -> Bundle Vector b
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector b
bs)
any6 :: (a -> b -> c -> d -> e -> f -> Bool)
-> Vector a
-> Vector b
-> Vector c
-> Vector d
-> Vector e
-> Vector f
-> Bool
any6 a -> b -> c -> d -> e -> f -> Bool
f Vector a
as Vector b
bs Vector c
cs Vector d
ds Vector e
es Vector f
fs = Bundle Vector Bool -> Bool
forall (v :: * -> *). Bundle v Bool -> Bool
B.or (Bundle Vector Bool -> Bool) -> Bundle Vector Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> d -> e -> f -> Bool)
-> Bundle Vector a
-> Bundle Vector b
-> Bundle Vector c
-> Bundle Vector d
-> Bundle Vector e
-> Bundle Vector f
-> Bundle Vector Bool
forall a b c d e f g (v :: * -> *).
(a -> b -> c -> d -> e -> f -> g)
-> Bundle v a
-> Bundle v b
-> Bundle v c
-> Bundle v d
-> Bundle v e
-> Bundle v f
-> Bundle v g
B.zipWith6 a -> b -> c -> d -> e -> f -> Bool
f
(Vector a -> Bundle Vector a
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector a
as) (Vector b -> Bundle Vector b
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector b
bs) (Vector c -> Bundle Vector c
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector c
cs) (Vector d -> Bundle Vector d
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector d
ds) (Vector e -> Bundle Vector e
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector e
es) (Vector f -> Bundle Vector f
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector f
fs)
any5 :: (a -> b -> c -> d -> e -> Bool)
-> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Bool
any5 a -> b -> c -> d -> e -> Bool
f Vector a
as Vector b
bs Vector c
cs Vector d
ds Vector e
es = Bundle Vector Bool -> Bool
forall (v :: * -> *). Bundle v Bool -> Bool
B.or (Bundle Vector Bool -> Bool) -> Bundle Vector Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> d -> e -> Bool)
-> Bundle Vector a
-> Bundle Vector b
-> Bundle Vector c
-> Bundle Vector d
-> Bundle Vector e
-> Bundle Vector Bool
forall a b c d e f (v :: * -> *).
(a -> b -> c -> d -> e -> f)
-> Bundle v a
-> Bundle v b
-> Bundle v c
-> Bundle v d
-> Bundle v e
-> Bundle v f
B.zipWith5 a -> b -> c -> d -> e -> Bool
f
(Vector a -> Bundle Vector a
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector a
as) (Vector b -> Bundle Vector b
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector b
bs) (Vector c -> Bundle Vector c
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector c
cs) (Vector d -> Bundle Vector d
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector d
ds) (Vector e -> Bundle Vector e
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector e
es)
any4 :: (a -> b -> c -> d -> Bool)
-> Vector a -> Vector b -> Vector c -> Vector d -> Bool
any4 a -> b -> c -> d -> Bool
f Vector a
as Vector b
bs Vector c
cs Vector d
ds = Bundle Vector Bool -> Bool
forall (v :: * -> *). Bundle v Bool -> Bool
B.or (Bundle Vector Bool -> Bool) -> Bundle Vector Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> d -> Bool)
-> Bundle Vector a
-> Bundle Vector b
-> Bundle Vector c
-> Bundle Vector d
-> Bundle Vector Bool
forall a b c d e (v :: * -> *).
(a -> b -> c -> d -> e)
-> Bundle v a
-> Bundle v b
-> Bundle v c
-> Bundle v d
-> Bundle v e
B.zipWith4 a -> b -> c -> d -> Bool
f
(Vector a -> Bundle Vector a
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector a
as) (Vector b -> Bundle Vector b
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector b
bs) (Vector c -> Bundle Vector c
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector c
cs) (Vector d -> Bundle Vector d
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector d
ds)
any3 :: (a -> b -> c -> Bool) -> Vector a -> Vector b -> Vector c -> Bool
any3 a -> b -> c -> Bool
f Vector a
as Vector b
bs Vector c
cs = Bundle Vector Bool -> Bool
forall (v :: * -> *). Bundle v Bool -> Bool
B.or (Bundle Vector Bool -> Bool) -> Bundle Vector Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> Bool)
-> Bundle Vector a
-> Bundle Vector b
-> Bundle Vector c
-> Bundle Vector Bool
forall a b c d (v :: * -> *).
(a -> b -> c -> d)
-> Bundle v a -> Bundle v b -> Bundle v c -> Bundle v d
B.zipWith3 a -> b -> c -> Bool
f
(Vector a -> Bundle Vector a
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector a
as) (Vector b -> Bundle Vector b
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector b
bs) (Vector c -> Bundle Vector c
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector c
cs)
any2 :: (a -> b -> Bool) -> Vector a -> Vector b -> Bool
any2 a -> b -> Bool
f Vector a
as Vector b
bs = Bundle Vector Bool -> Bool
forall (v :: * -> *). Bundle v Bool -> Bool
B.or (Bundle Vector Bool -> Bool) -> Bundle Vector Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (a -> b -> Bool)
-> Bundle Vector a -> Bundle Vector b -> Bundle Vector Bool
forall a b c (v :: * -> *).
(a -> b -> c) -> Bundle v a -> Bundle v b -> Bundle v c
B.zipWith a -> b -> Bool
f (Vector a -> Bundle Vector a
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector a
as) (Vector b -> Bundle Vector b
forall (v :: * -> *) a. Vector v a => v a -> Bundle v a
stream Vector b
bs)
zipWith :: (a -> b -> c) -> Vector a -> Vector b -> Vector c
zipWith = (a -> b -> c) -> Vector a -> Vector b -> Vector c
forall a b c. (a -> b -> c) -> Vector a -> Vector b -> Vector c
V.zipWith
zipWith3 :: (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
zipWith3 = (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
forall a b c d.
(a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
V.zipWith3
zipWith4 :: (a -> b -> c -> d -> e)
-> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
zipWith4 = (a -> b -> c -> d -> e)
-> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
forall a b c d e.
(a -> b -> c -> d -> e)
-> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
V.zipWith4
zipWith5 :: (a -> b -> c -> d -> e -> f)
-> Vector a
-> Vector b
-> Vector c
-> Vector d
-> Vector e
-> Vector f
zipWith5 = (a -> b -> c -> d -> e -> f)
-> Vector a
-> Vector b
-> Vector c
-> Vector d
-> Vector e
-> Vector f
forall a b c d e f.
(a -> b -> c -> d -> e -> f)
-> Vector a
-> Vector b
-> Vector c
-> Vector d
-> Vector e
-> Vector f
V.zipWith5
zipWith6 :: (a -> b -> c -> d -> e -> f -> g)
-> Vector a
-> Vector b
-> Vector c
-> Vector d
-> Vector e
-> Vector f
-> Vector g
zipWith6 = (a -> b -> c -> d -> e -> f -> g)
-> Vector a
-> Vector b
-> Vector c
-> Vector d
-> Vector e
-> Vector f
-> Vector g
forall a b c d e f g.
(a -> b -> c -> d -> e -> f -> g)
-> Vector a
-> Vector b
-> Vector c
-> Vector d
-> Vector e
-> Vector f
-> Vector g
V.zipWith6
instance Scan (Vector e) e
instance Estimate (Vector e)
where
<==> :: Compare (Vector e)
(<==>) = (Int -> Int -> Ordering) -> (Vector e -> Int) -> Compare (Vector e)
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Int -> Int -> Ordering
forall o. Ord o => Compare o
(<=>) Vector e -> Int
forall b i. Bordered b i => b -> Int
sizeOf
.>. :: Vector e -> Vector e -> Bool
(.>.) = (Int -> Int -> Bool)
-> (Vector e -> Int) -> Vector e -> Vector e -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
(>) Vector e -> Int
forall b i. Bordered b i => b -> Int
sizeOf
.<. :: Vector e -> Vector e -> Bool
(.<.) = (Int -> Int -> Bool)
-> (Vector e -> Int) -> Vector e -> Vector e -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
(<) Vector e -> Int
forall b i. Bordered b i => b -> Int
sizeOf
.<=. :: Vector e -> Vector e -> Bool
(.<=.) = (Int -> Int -> Bool)
-> (Vector e -> Int) -> Vector e -> Vector e -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
(<=) Vector e -> Int
forall b i. Bordered b i => b -> Int
sizeOf
.>=. :: Vector e -> Vector e -> Bool
(.>=.) = (Int -> Int -> Bool)
-> (Vector e -> Int) -> Vector e -> Vector e -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
(>=) Vector e -> Int
forall b i. Bordered b i => b -> Int
sizeOf
<.=> :: Vector e -> Int -> Ordering
(<.=>) = Int -> Int -> Ordering
forall o. Ord o => Compare o
(<=>) (Int -> Int -> Ordering)
-> (Vector e -> Int) -> Vector e -> Int -> Ordering
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector e -> Int
forall b i. Bordered b i => b -> Int
sizeOf
.> :: Vector e -> Int -> Bool
(.>) = Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
(>) (Int -> Int -> Bool)
-> (Vector e -> Int) -> Vector e -> Int -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector e -> Int
forall b i. Bordered b i => b -> Int
sizeOf
.< :: Vector e -> Int -> Bool
(.<) = Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
(<) (Int -> Int -> Bool)
-> (Vector e -> Int) -> Vector e -> Int -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector e -> Int
forall b i. Bordered b i => b -> Int
sizeOf
.>= :: Vector e -> Int -> Bool
(.>=) = Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
(>=) (Int -> Int -> Bool)
-> (Vector e -> Int) -> Vector e -> Int -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector e -> Int
forall b i. Bordered b i => b -> Int
sizeOf
.<= :: Vector e -> Int -> Bool
(.<=) = Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
(<=) (Int -> Int -> Bool)
-> (Vector e -> Int) -> Vector e -> Int -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector e -> Int
forall b i. Bordered b i => b -> Int
sizeOf
instance Linear (Vector e) e
where
single :: e -> Vector e
single = e -> Vector e
forall e. e -> Vector e
V.singleton
toHead :: e -> Vector e -> Vector e
toHead = e -> Vector e -> Vector e
forall e. e -> Vector e -> Vector e
V.cons
toLast :: Vector e -> e -> Vector e
toLast = Vector e -> e -> Vector e
forall e. Vector e -> e -> Vector e
V.snoc
listL :: Vector e -> [e]
listL = Vector e -> [e]
forall e. Vector e -> [e]
V.toList
force :: Vector e -> Vector e
force = Vector e -> Vector e
forall e. Vector e -> Vector e
V.force
head :: Vector e -> e
head = Vector e -> e
forall e. Vector e -> e
V.head
tail :: Vector e -> Vector e
tail = Vector e -> Vector e
forall e. Vector e -> Vector e
V.tail
init :: Vector e -> Vector e
init = Vector e -> Vector e
forall e. Vector e -> Vector e
V.init
last :: Vector e -> e
last = Vector e -> e
forall e. Vector e -> e
V.last
nub :: Vector e -> Vector e
nub = Vector e -> Vector e
forall e. Eq e => Vector e -> Vector e
V.uniq
!^ :: Vector e -> Int -> e
(!^) = Vector e -> Int -> e
forall e. Vector e -> Int -> e
V.unsafeIndex
++ :: Vector e -> Vector e -> Vector e
(++) = Vector e -> Vector e -> Vector e
forall e. Vector e -> Vector e -> Vector e
(V.++)
write :: Vector e -> Int -> e -> Vector e
write Vector e
es = (Vector e
es Vector e -> [(Int, e)] -> Vector e
forall map key e. Map map key e => map -> [(key, e)] -> map
//) ([(Int, e)] -> Vector e)
-> ((Int, e) -> [(Int, e)]) -> (Int, e) -> Vector e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, e) -> [(Int, e)]
forall l e. Linear l e => e -> l
single ((Int, e) -> Vector e)
-> (Int -> e -> (Int, e)) -> Int -> e -> Vector e
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
... (,)
partitions :: f (e -> Bool) -> Vector e -> [Vector e]
partitions f (e -> Bool)
ps = ([e] -> Vector e) -> [[e]] -> [Vector e]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [e] -> Vector e
forall l e. Linear l e => [e] -> l
fromList ([[e]] -> [Vector e])
-> (Vector e -> [[e]]) -> Vector e -> [Vector e]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f (e -> Bool) -> [e] -> [[e]]
forall l e (f :: * -> *).
(Linear l e, Foldable f) =>
f (e -> Bool) -> l -> [l]
partitions f (e -> Bool)
ps ([e] -> [[e]]) -> (Vector e -> [e]) -> Vector e -> [[e]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector e -> [e]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
concatMap :: (a -> Vector e) -> f a -> Vector e
concatMap a -> Vector e
f = (a -> Vector e) -> Vector a -> Vector e
forall a b. (a -> Vector b) -> Vector a -> Vector b
V.concatMap a -> Vector e
f (Vector a -> Vector e) -> (f a -> Vector a) -> f a -> Vector e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> Vector a
forall l e (f :: * -> *). (Linear l e, Foldable f) => f e -> l
fromFoldable
fromListN :: Int -> [e] -> Vector e
fromListN = Int -> [e] -> Vector e
forall e. Int -> [e] -> Vector e
V.fromListN
replicate :: Int -> e -> Vector e
replicate = Int -> e -> Vector e
forall e. Int -> e -> Vector e
V.replicate
partition :: (e -> Bool) -> Vector e -> (Vector e, Vector e)
partition = (e -> Bool) -> Vector e -> (Vector e, Vector e)
forall e. (e -> Bool) -> Vector e -> (Vector e, Vector e)
V.partition
fromList :: [e] -> Vector e
fromList = [e] -> Vector e
forall e. [e] -> Vector e
V.fromList
reverse :: Vector e -> Vector e
reverse = Vector e -> Vector e
forall e. Vector e -> Vector e
V.reverse
concat :: f (Vector e) -> Vector e
concat = [Vector e] -> Vector e
forall a. [Vector a] -> Vector a
V.concat ([Vector e] -> Vector e)
-> (f (Vector e) -> [Vector e]) -> f (Vector e) -> Vector e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f (Vector e) -> [Vector e]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
filter :: (e -> Bool) -> Vector e -> Vector e
filter = (e -> Bool) -> Vector e -> Vector e
forall e. (e -> Bool) -> Vector e -> Vector e
V.filter
ofoldl :: (Int -> b -> e -> b) -> b -> Vector e -> b
ofoldl = (b -> Int -> e -> b) -> b -> Vector e -> b
forall a b. (a -> Int -> b -> a) -> a -> Vector b -> a
V.ifoldl ((b -> Int -> e -> b) -> b -> Vector e -> b)
-> ((Int -> b -> e -> b) -> b -> Int -> e -> b)
-> (Int -> b -> e -> b)
-> b
-> Vector e
-> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> b -> e -> b) -> b -> Int -> e -> b
forall a b c. (a -> b -> c) -> b -> a -> c
flip
ofoldr :: (Int -> e -> b -> b) -> b -> Vector e -> b
ofoldr = (Int -> e -> b -> b) -> b -> Vector e -> b
forall e b. (Int -> e -> b -> b) -> b -> Vector e -> b
V.ifoldr
o_foldl :: (b -> e -> b) -> b -> Vector e -> b
o_foldl = (b -> e -> b) -> b -> Vector e -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl
o_foldr :: (e -> b -> b) -> b -> Vector e -> b
o_foldr = (e -> b -> b) -> b -> Vector e -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr
instance Split (Vector e) e
where
take :: Int -> Vector e -> Vector e
take = Int -> Vector e -> Vector e
forall e. Int -> Vector e -> Vector e
V.take
drop :: Int -> Vector e -> Vector e
drop = Int -> Vector e -> Vector e
forall e. Int -> Vector e -> Vector e
V.drop
split :: Int -> Vector e -> (Vector e, Vector e)
split = Int -> Vector e -> (Vector e, Vector e)
forall e. Int -> Vector e -> (Vector e, Vector e)
V.splitAt
takeWhile :: (e -> Bool) -> Vector e -> Vector e
takeWhile = (e -> Bool) -> Vector e -> Vector e
forall e. (e -> Bool) -> Vector e -> Vector e
V.takeWhile
dropWhile :: (e -> Bool) -> Vector e -> Vector e
dropWhile = (e -> Bool) -> Vector e -> Vector e
forall e. (e -> Bool) -> Vector e -> Vector e
V.dropWhile
spanl :: (e -> Bool) -> Vector e -> (Vector e, Vector e)
spanl = (e -> Bool) -> Vector e -> (Vector e, Vector e)
forall e. (e -> Bool) -> Vector e -> (Vector e, Vector e)
V.span
breakl :: (e -> Bool) -> Vector e -> (Vector e, Vector e)
breakl = (e -> Bool) -> Vector e -> (Vector e, Vector e)
forall e. (e -> Bool) -> Vector e -> (Vector e, Vector e)
V.break
instance Bordered (Vector e) Int
where
lower :: Vector e -> Int
lower Vector e
_ = Int
0
upper :: Vector e -> Int
upper Vector e
es = Vector e -> Int
forall b i. Bordered b i => b -> Int
sizeOf Vector e
es Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1
bounds :: Vector e -> (Int, Int)
bounds Vector e
es = (Int
0, Vector e -> Int
forall b i. Bordered b i => b -> Int
sizeOf Vector e
es Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)
sizeOf :: Vector e -> Int
sizeOf = Vector e -> Int
forall e. Vector e -> Int
V.length
instance Map (Vector e) Int e
where
toMap :: [(Int, e)] -> Vector e
toMap [(Int, e)]
ascs = [(Int, e)] -> Bool
forall e. Nullable e => e -> Bool
isNull [(Int, e)]
ascs Bool -> Vector e -> Vector e -> Vector e
forall a. Bool -> a -> a -> a
? Vector e
forall e. Nullable e => e
Z (Vector e -> Vector e) -> Vector e -> Vector e
forall a b. (a -> b) -> a -> b
$ (Int, Int) -> [(Int, e)] -> Vector e
forall v i e. Indexed v i e => (i, i) -> [(i, e)] -> v
assoc (Int
l, Int
u) [(Int, e)]
ascs
where
l :: Int
l = (Int, e) -> Int
forall a b. (a, b) -> a
fst ((Int, e) -> Int) -> (Int, e) -> Int
forall a b. (a -> b) -> a -> b
$ ((Int, e) -> (Int, e) -> Ordering) -> [(Int, e)] -> (Int, e)
forall (t :: * -> *) a.
Foldable t =>
(a -> a -> Ordering) -> t a -> a
minimumBy (Int, e) -> (Int, e) -> Ordering
forall o s. Ord o => Compare (o, s)
cmpfst [(Int, e)]
ascs
u :: Int
u = (Int, e) -> Int
forall a b. (a, b) -> a
fst ((Int, e) -> Int) -> (Int, e) -> Int
forall a b. (a -> b) -> a -> b
$ ((Int, e) -> (Int, e) -> Ordering) -> [(Int, e)] -> (Int, e)
forall (t :: * -> *) a.
Foldable t =>
(a -> a -> Ordering) -> t a -> a
maximumBy (Int, e) -> (Int, e) -> Ordering
forall o s. Ord o => Compare (o, s)
cmpfst [(Int, e)]
ascs
toMap' :: e -> [(Int, e)] -> Vector e
toMap' e
defvalue [(Int, e)]
ascs = [(Int, e)] -> Bool
forall e. Nullable e => e -> Bool
isNull [(Int, e)]
ascs Bool -> Vector e -> Vector e -> Vector e
forall a. Bool -> a -> a -> a
? Vector e
forall e. Nullable e => e
Z (Vector e -> Vector e) -> Vector e -> Vector e
forall a b. (a -> b) -> a -> b
$ (Int, Int) -> e -> [(Int, e)] -> Vector e
forall v i e. Indexed v i e => (i, i) -> e -> [(i, e)] -> v
assoc' (Int
l, Int
u) e
defvalue [(Int, e)]
ascs
where
l :: Int
l = (Int, e) -> Int
forall a b. (a, b) -> a
fst ((Int, e) -> Int) -> (Int, e) -> Int
forall a b. (a -> b) -> a -> b
$ ((Int, e) -> (Int, e) -> Ordering) -> [(Int, e)] -> (Int, e)
forall (t :: * -> *) a.
Foldable t =>
(a -> a -> Ordering) -> t a -> a
minimumBy (Int, e) -> (Int, e) -> Ordering
forall o s. Ord o => Compare (o, s)
cmpfst [(Int, e)]
ascs
u :: Int
u = (Int, e) -> Int
forall a b. (a, b) -> a
fst ((Int, e) -> Int) -> (Int, e) -> Int
forall a b. (a -> b) -> a -> b
$ ((Int, e) -> (Int, e) -> Ordering) -> [(Int, e)] -> (Int, e)
forall (t :: * -> *) a.
Foldable t =>
(a -> a -> Ordering) -> t a -> a
maximumBy (Int, e) -> (Int, e) -> Ordering
forall o s. Ord o => Compare (o, s)
cmpfst [(Int, e)]
ascs
Vector e
Z // :: Vector e -> [(Int, e)] -> Vector e
// [(Int, e)]
ascs = [(Int, e)] -> Vector e
forall map key e. Map map key e => [(key, e)] -> map
toMap [(Int, e)]
ascs
Vector e
vs // [(Int, e)]
ascs = Vector e
vs Vector e -> [(Int, e)] -> Vector e
forall e. Vector e -> [(Int, e)] -> Vector e
V.// [(Int, e)]
ascs
*$ :: (e -> Bool) -> Vector e -> [Int]
(*$) = Vector Int -> [Int]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (Vector Int -> [Int])
-> ((e -> Bool) -> Vector e -> Vector Int)
-> (e -> Bool)
-> Vector e
-> [Int]
forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
... (e -> Bool) -> Vector e -> Vector Int
forall a. (a -> Bool) -> Vector a -> Vector Int
V.findIndices
.! :: Vector e -> Int -> e
(.!) = Vector e -> Int -> e
forall e. Vector e -> Int -> e
V.unsafeIndex
.$ :: (e -> Bool) -> Vector e -> Maybe Int
(.$) = (e -> Bool) -> Vector e -> Maybe Int
forall e. (e -> Bool) -> Vector e -> Maybe Int
V.findIndex
!? :: Vector e -> Int -> Maybe e
(!?) = Vector e -> Int -> Maybe e
forall e. Vector e -> Int -> Maybe e
(V.!?)
kfoldl :: (Int -> b -> e -> b) -> b -> Vector e -> b
kfoldl = (Int -> b -> e -> b) -> b -> Vector e -> b
forall l e b. Linear l e => (Int -> b -> e -> b) -> b -> l -> b
ofoldl
kfoldr :: (Int -> e -> b -> b) -> b -> Vector e -> b
kfoldr = (Int -> e -> b -> b) -> b -> Vector e -> b
forall l e b. Linear l e => (Int -> e -> b -> b) -> b -> l -> b
ofoldr
instance Indexed (Vector e) Int e
where
assoc' :: (Int, Int) -> e -> [(Int, e)] -> Vector e
assoc' (Int, Int)
bnds e
defvalue [(Int, e)]
ascs = (forall s. ST s (Vector e)) -> Vector e
forall a. (forall s. ST s a) -> a
runST ((forall s. ST s (Vector e)) -> Vector e)
-> (forall s. ST s (Vector e)) -> Vector e
forall a b. (a -> b) -> a -> b
$ (Int, Int) -> e -> [(Int, e)] -> ST s (STArray# s e)
forall (m :: * -> *) v i e.
IndexedM m v i e =>
(i, i) -> e -> [(i, e)] -> m v
fromAssocs' (Int, Int)
bnds e
defvalue [(Int, e)]
ascs ST s (STArray# s e)
-> (STArray# s e -> ST s (Vector e)) -> ST s (Vector e)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= STArray# s e -> ST s (Vector e)
forall s e. STArray# s e -> ST s (Vector e)
done
fromIndexed :: m -> Vector e
fromIndexed m
es' = (e -> e -> e) -> Vector e -> [(Int, e)] -> Vector e
forall v i e e'.
Indexed v i e =>
(e -> e' -> e) -> v -> [(i, e')] -> v
accum ((e -> e -> e) -> e -> e -> e
forall a b c. (a -> b -> c) -> b -> a -> c
flip e -> e -> e
forall a b. a -> b -> a
const) Vector e
es [(Int, e)]
ies
where
ies :: [(Int, e)]
ies = [ ((j, j) -> j -> Int
forall i. Index i => (i, i) -> i -> Int
offset (j, j)
bnds j
i, e
e) | (j
i, e
e) <- m -> [(j, e)]
forall map key e. Map map key e => map -> [(key, e)]
assocs m
es', (j, j) -> j -> Bool
forall i. Index i => (i, i) -> i -> Bool
inRange (j, j)
bnds j
i ]
es :: Vector e
es = Int -> e -> Vector e
forall l e. Linear l e => Int -> e -> l
replicate ((j, j) -> Int
forall i. Index i => (i, i) -> Int
size (j, j)
bnds) e
forall a. HasCallStack => a
undefined
bnds :: (j, j)
bnds = m -> (j, j)
forall b i. Bordered b i => b -> (i, i)
bounds m
es'
instance Sort (Vector e) e
where
sortBy :: Compare e -> Vector e -> Vector e
sortBy Compare e
cmp Vector e
es = (forall s. ST s (Vector e)) -> Vector e
forall a. (forall s. ST s a) -> a
runST ((forall s. ST s (Vector e)) -> Vector e)
-> (forall s. ST s (Vector e)) -> Vector e
forall a b. (a -> b) -> a -> b
$ do STArray# s e
es' <- Vector e -> ST s (STArray# s e)
forall (m :: * -> *) v v'. Thaw m v v' => v -> m v'
thaw Vector e
es; Compare e -> STArray# s e -> ST s ()
forall (m :: * -> *) v e i.
(LinearM m v e, BorderedM m v i) =>
Compare e -> v -> m ()
timSortBy Compare e
cmp STArray# s e
es'; STArray# s e -> ST s (Vector e)
forall s e. STArray# s e -> ST s (Vector e)
done STArray# s e
es'
sortedBy :: (e -> e -> Bool) -> Vector e -> Bool
sortedBy e -> e -> Bool
f = (e -> e -> Bool) -> [e] -> Bool
forall s e. Sort s e => (e -> e -> Bool) -> s -> Bool
sortedBy e -> e -> Bool
f ([e] -> Bool) -> (Vector e -> [e]) -> Vector e -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector e -> [e]
forall l e. Linear l e => l -> [e]
listL
instance Thaw (ST s) (Vector e) (STArray# s e) where thaw :: Vector e -> ST s (STArray# s e)
thaw = Vector e -> ST s (STArray# s e)
forall (m :: * -> *) l e (f :: * -> *).
(LinearM m l e, Foldable f) =>
f e -> m l
fromFoldableM
instance Thaw (ST s) (Vector e) (STUnlist s e) where thaw :: Vector e -> ST s (STUnlist s e)
thaw = Vector e -> ST s (STUnlist s e)
forall (m :: * -> *) l e (f :: * -> *).
(LinearM m l e, Foldable f) =>
f e -> m l
fromFoldableM
instance (MonadIO io) => Thaw io (Vector e) (MIOArray# io e) where thaw :: Vector e -> io (MIOArray# io e)
thaw = Vector e -> io (MIOArray# io e)
forall (m :: * -> *) l e (f :: * -> *).
(LinearM m l e, Foldable f) =>
f e -> m l
fromFoldableM
instance (MonadIO io) => Thaw io (Vector e) (MIOUnlist io e) where thaw :: Vector e -> io (MIOUnlist io e)
thaw = Vector e -> io (MIOUnlist io e)
forall (m :: * -> *) l e (f :: * -> *).
(LinearM m l e, Foldable f) =>
f e -> m l
fromFoldableM
instance Freeze (ST s) (STArray# s e) (Vector e) where freeze :: STArray# s e -> ST s (Vector e)
freeze = ([e] -> Vector e) -> ST s [e] -> ST s (Vector e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [e] -> Vector e
forall l e. Linear l e => [e] -> l
fromList (ST s [e] -> ST s (Vector e))
-> (STArray# s e -> ST s [e]) -> STArray# s e -> ST s (Vector e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STArray# s e -> ST s [e]
forall (m :: * -> *) l e. LinearM m l e => l -> m [e]
getLeft
instance Freeze (ST s) (STUnlist s e) (Vector e) where freeze :: STUnlist s e -> ST s (Vector e)
freeze = ([e] -> Vector e) -> ST s [e] -> ST s (Vector e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [e] -> Vector e
forall l e. Linear l e => [e] -> l
fromList (ST s [e] -> ST s (Vector e))
-> (STUnlist s e -> ST s [e]) -> STUnlist s e -> ST s (Vector e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. STUnlist s e -> ST s [e]
forall (m :: * -> *) l e. LinearM m l e => l -> m [e]
getLeft
instance (MonadIO io) => Freeze io (MIOArray# io e) (Vector e) where freeze :: MIOArray# io e -> io (Vector e)
freeze = ([e] -> Vector e) -> io [e] -> io (Vector e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [e] -> Vector e
forall l e. Linear l e => [e] -> l
fromList (io [e] -> io (Vector e))
-> (MIOArray# io e -> io [e]) -> MIOArray# io e -> io (Vector e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MIOArray# io e -> io [e]
forall (m :: * -> *) l e. LinearM m l e => l -> m [e]
getLeft
instance (MonadIO io) => Freeze io (MIOUnlist io e) (Vector e) where freeze :: MIOUnlist io e -> io (Vector e)
freeze = ([e] -> Vector e) -> io [e] -> io (Vector e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [e] -> Vector e
forall l e. Linear l e => [e] -> l
fromList (io [e] -> io (Vector e))
-> (MIOUnlist io e -> io [e]) -> MIOUnlist io e -> io (Vector e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MIOUnlist io e -> io [e]
forall (m :: * -> *) l e. LinearM m l e => l -> m [e]
getLeft
done :: STArray# s e -> ST s (Vector e)
done :: STArray# s e -> ST s (Vector e)
done = STArray# s e -> ST s (Vector e)
forall (m :: * -> *) v' v. Freeze m v' v => v' -> m v
freeze