indexation 0.6.4 → 0.6.4.1
raw patch · 3 files changed
+14/−9 lines, 3 filesdep ~dense-int-setPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: dense-int-set
API changes (from Hackage documentation)
Files
- indexation.cabal +2/−2
- library/Indexation/Functions.hs +2/−2
- library/Indexation/Utils/Vector.hs +10/−5
indexation.cabal view
@@ -1,5 +1,5 @@ name: indexation-version: 0.6.4+version: 0.6.4.1 category: Data synopsis: Tools for entity indexation description: A set of tools for indexing entities@@ -43,7 +43,7 @@ contravariant >=1.4 && <2, deepseq >=1.4.3 && <2, deferred-folds >=0.9.6 && <0.10,- dense-int-set >=0.1.5 && <0.2,+ dense-int-set >=0.2 && <0.3, focus >=1.0.1 && <1.1, foldl >=1 && <2, hashable >=1 && <2,
library/Indexation/Functions.hs view
@@ -47,10 +47,10 @@ countIndexSet (IndexSet set) = DenseIntSet.size set newIndexToOldIndexTable :: IndexSet a -> EntityTable (Index a)-newIndexToOldIndexTable (IndexSet set) = EntityTable (coerce (DenseIntSet.presentElementsVector set :: Vector Int))+newIndexToOldIndexTable (IndexSet set) = EntityTable (DenseIntSet.presentElementsVector set Index) oldIndexToNewIndexTable :: IndexSet a -> ReindexTable a-oldIndexToNewIndexTable (IndexSet set) = ReindexTable (DenseIntSet.indexVector set)+oldIndexToNewIndexTable (IndexSet set) = ReindexTable (DenseIntSet.indexVector set id) filterEntityTable :: IndexSet a -> EntityTable a -> EntityTable a filterEntityTable (IndexSet set) (EntityTable vec) = EntityTable (DenseIntSet.filterVector set vec)
library/Indexation/Utils/Vector.hs view
@@ -6,6 +6,7 @@ import qualified Data.Vector.Mutable as MutableVector import qualified Data.HashMap.Strict as HashMap import qualified DeferredFolds.UnfoldlM as UnfoldlM+import qualified DeferredFolds.Unfoldr as Unfoldr import qualified ListT @@ -34,13 +35,17 @@ -} {-# INLINE indexHashMapWithSize #-} indexHashMapWithSize :: Int -> HashMap element Int -> Vector element-indexHashMapWithSize size hashMap =+indexHashMapWithSize size = unfoldrWithSize size . fmap swap . Unfoldr.hashMapAssocs++{-|+This function is partial. It doesn't check the size or indices.+-}+{-# INLINE unfoldrWithSize #-}+unfoldrWithSize :: Int -> Unfoldr (Int, element) -> Vector element+unfoldrWithSize size unfoldr = runST $ do mv <- MutableVector.new size- HashMap.foldrWithKey- (\ element index action -> MutableVector.write mv index element >> action)- (return ())- hashMap+ Indexation.Prelude.forM_ unfoldr $ \ (index, element) -> MutableVector.write mv index element freeze mv {-# NOINLINE unfoldlM #-}