[{"name":"RandomTree.Uniform","comment":" This module provides data structure subjected to random choice of elements in uniform probability.\n\n\n## Note\n\n`Tree` in this module\n\n  - is not allowed to be empty, so\n      - the return value of function that reduce the number of element(`take`, `remove`, and `filter`) all return `Maybe (Tree a)` just in case all the elements are deleted.\n      - You have to pass at least one element at the creation, so function like `fromList` takes one heading element and tailing list.(similar with `Random.uniform` or `Random.weighted`.)\n  - is not a search tree(the elements are not ordered), so the time complexity of `member` and `remove` is _O(N)_.\n  - may be unbalanced when `remove` or `filter` is called, so when I say \"The time complexity is _O(log(N))_\", _N_ denotes the maximal size in the history of the tree so far.\n\n\n# Types\n\n@docs Tree\n\n\n# Creation\n\n@docs singleton, fromList\n\n\n# Insertion\n\n@docs insert, insertList\n\n\n# Modification\n\n@docs map, filter, remove\n\n\n# Random Picking Up\n\n@docs get, take, replace\n\n\n# Status Checking\n\n@docs count\n\n","unions":[{"name":"Tree","comment":" Type that represents binary tree with elements subjected to random picking up in uniform probabilities.\n","args":["a"],"cases":[]}],"aliases":[],"values":[{"name":"count","comment":" Returns how many elements the tree has.\n","type":"RandomTree.Uniform.Tree a -> Basics.Int"},{"name":"filter","comment":" Removes any number of elements which fails to passes the test function given as the first parameter.\n","type":"(a -> Basics.Bool) -> RandomTree.Uniform.Tree a -> Maybe.Maybe (RandomTree.Uniform.Tree a)"},{"name":"fromList","comment":" Returns a `Tree` that has all elements in given list.\n","type":"a -> List.List a -> RandomTree.Uniform.Tree a"},{"name":"get","comment":" Random generator that generates one of the elements conteined in `Tree` given as parameter.\nThe time complexity is _O(log(N))_.\n","type":"RandomTree.Uniform.Tree a -> Random.Generator a"},{"name":"insert","comment":" Inserts a data to an already-existing `Tree`.\n","type":"a -> RandomTree.Uniform.Tree a -> RandomTree.Uniform.Tree a"},{"name":"insertList","comment":" Inserts all elements of given list into the tree.\n","type":"List.List a -> RandomTree.Uniform.Tree a -> RandomTree.Uniform.Tree a"},{"name":"map","comment":" Maps all the content of the tree.\n","type":"(a -> b) -> RandomTree.Uniform.Tree a -> RandomTree.Uniform.Tree b"},{"name":"remove","comment":" Removes any number of elements which is the same as the first parameter from the second parameter.\n","type":"a -> RandomTree.Uniform.Tree a -> Maybe.Maybe (RandomTree.Uniform.Tree a)"},{"name":"replace","comment":" Random generator that replaces one data from the tree and generates a pair consisting of the removed data and resultant tree. For example,\n\n    replace x  ／＼\n             ／    ＼\n           ／＼    ／＼\n         ／＼  c  d    e\n        a    b\n\ngenerates\n\n    ( a，  ／＼    ),\n         ／    ＼\n       ／＼    ／＼\n     ／＼  c  d    e\n    x    b\n\n    ( b，  ／＼    ),\n         ／    ＼\n       ／＼    ／＼\n     ／＼  c  d    e\n    a    x\n\n    ( c，  ／＼    ),\n         ／    ＼\n       ／＼    ／＼\n     ／＼  x  d    e\n    a    b\n\n    ( d，  ／＼    ),\n         ／    ＼\n       ／＼    ／＼\n     ／＼  c  x    e\n    a    b\n\nor\n\n    ( e，  ／＼    ),\n         ／    ＼\n       ／＼    ／＼\n     ／＼  c  d    x\n    a    b\n\nin probability of 20%. The time complexity is _O(log(N))_.\n\n","type":"a -> RandomTree.Uniform.Tree a -> Random.Generator ( a, RandomTree.Uniform.Tree a )"},{"name":"singleton","comment":" Returns a `Tree` that has only one element.\n","type":"a -> RandomTree.Uniform.Tree a"},{"name":"take","comment":" Random generator that generates one of the elements conteined in `Tree`, paired with the rest part of the tree. For example,\n\n    take\n            ／＼\n          ／    ＼\n        ／＼    ／＼\n      ／＼  c  d    e\n     a    b\n\ngenerates\n\n    ( a， Just  ／＼    ),\n              ／    ＼\n            ／＼    ／＼\n           b    c  d    e\n\n    ( b，Just   ／＼    ),\n              ／    ＼\n            ／＼    ／＼\n           a    c  d    e\n\n    ( c，Just  ／＼    ),\n             ／    ＼\n          ／＼     ／＼\n          a    b  d    e\n\n    ( d，Just   ／＼    ),\n              ／    ＼\n            ／＼    ／＼\n           a    b  c    e\n\nor\n\n    ( e，Just   ／＼    )\n              ／    ＼\n            ／＼    ／＼\n           a    b  c    d\n\nin probability of 20%. The time complexity is _O(log(N))_.\n\n","type":"RandomTree.Uniform.Tree a -> Random.Generator ( a, Maybe.Maybe (RandomTree.Uniform.Tree a) )"}],"binops":[]},{"name":"RandomTree.Weighted","comment":" This module provides a data structure that allows for random selection from a collection of data in amortized _O(log(N))_ time. You can assign a weight to each element as a `Float` value.\n\n\n## Note\n\nThe `Tree` in this module:\n\n  - cannot be empty. Consequently:\n      - Functions that reduce the number of elements (`pick`, `take`, `drop`, `remove`, and `filter`) return `Maybe (Tree a)` in the event that all elements are deleted.\n      - At least one element must be provided during creation, so `fromList` requires a head element and a tail list (similar to `Random.uniform` or `Random.weighted`).\n  - cannot contain elements with negative weights. If such weights are provided, they are automatically converted to their absolute values. While this may lead to errors, wrapping all operations in `Maybe` would be more cumbersome.\n  - is not a search tree (the elements are not ordered), resulting in a time complexity of _O(N)_ for `member` and `remove`.\n\n\n# Type\n\n@docs Tree\n\n\n# Query\n\n@docs getWeight\n\n\n# Creation\n\n@docs singleton, fromList\n\n\n# Random Operations\n\nThese functions all return `Random.Generator`.\n\n@docs get, pick, take, drop\n\n\n# Modification\n\n@docs map, mapContent, mapWeight, adjustTotalWeightTo\n\n\n# Addition\n\n@docs insert, insertList, merge\n\n\n# Deletion\n\nThese functions return `Maybe` if all elements are removed.\n\n@docs remove, filter\n\n\n# Destructure\n\n@docs toList\n\n","unions":[{"name":"Tree","comment":" `RandomTree.Weighted.Tree` represents non-empty collection of randomly chosen values.\n","args":["a"],"cases":[]}],"aliases":[],"values":[{"name":"adjustTotalWeightTo","comment":" Adjusts the total weight of the tree to the specified value.\n","type":"Basics.Float -> RandomTree.Weighted.Tree a -> RandomTree.Weighted.Tree a"},{"name":"drop","comment":" Returns `Random.Generator` that generates the argument tree whose `n` elements are removed randomly. The returned value is wrapped in `Maybe` just in case all the elements have been removed.\n","type":"Basics.Int -> RandomTree.Weighted.Tree a -> Random.Generator (Maybe.Maybe (RandomTree.Weighted.Tree a))"},{"name":"filter","comment":" Filters the `RandomTree.Weighted.Tree` by removing elements that do not satisfy the provided predicate function. The result is wrapped in a `Maybe` type to indicate if the tree is empty after filtering.\n","type":"(( Basics.Float, a ) -> Basics.Bool) -> RandomTree.Weighted.Tree a -> Maybe.Maybe (RandomTree.Weighted.Tree a)"},{"name":"fromList","comment":" Creates a `RandomTree.Weighted.Tree` from a single element and a list of additional elements. This ensures that the tree is non-empty.\n","type":"( Basics.Float, a ) -> List.List ( Basics.Float, a ) -> RandomTree.Weighted.Tree a"},{"name":"get","comment":" Returns a `Random.Generator` that produces a tuple containing a random content from the tree and its associated weight.\n","type":"RandomTree.Weighted.Tree a -> Random.Generator ( Basics.Float, a )"},{"name":"getWeight","comment":" Returns the weight of the specified `RandomTree.Weighted.Tree`.\n","type":"RandomTree.Weighted.Tree a -> Basics.Float"},{"name":"insert","comment":" Inserts a weighted element into the `RandomTree.Weighted.Tree`, adjusting the structure as needed.\n","type":"( Basics.Float, a ) -> RandomTree.Weighted.Tree a -> RandomTree.Weighted.Tree a"},{"name":"insertList","comment":" Inserts all weighted elements from the provided list into the `RandomTree.Weighted.Tree`.\n","type":"List.List ( Basics.Float, a ) -> RandomTree.Weighted.Tree a -> RandomTree.Weighted.Tree a"},{"name":"map","comment":" Maps the weighted contents of the tree using the provided function.\n","type":"(( Basics.Float, a ) -> ( Basics.Float, a )) -> RandomTree.Weighted.Tree a -> RandomTree.Weighted.Tree a"},{"name":"mapContent","comment":" Maps the content of each element in the tree using the provided function.\n","type":"(( Basics.Float, a ) -> a) -> RandomTree.Weighted.Tree a -> RandomTree.Weighted.Tree a"},{"name":"mapWeight","comment":" Maps the weight of each element in the tree using the provided function.\n","type":"(( Basics.Float, a ) -> Basics.Float) -> RandomTree.Weighted.Tree a -> RandomTree.Weighted.Tree a"},{"name":"merge","comment":" Merges two `RandomTree.Weighted.Tree` instances into a single tree, preserving weights of each elements.\n","type":"RandomTree.Weighted.Tree a -> RandomTree.Weighted.Tree a -> RandomTree.Weighted.Tree a"},{"name":"pick","comment":" Returns a `Random.Generator` that produces a tuple containing a randomly selected weighted content from the tree and a `Maybe` value representing the modified tree with that content removed.\n","type":"RandomTree.Weighted.Tree a -> Random.Generator ( ( Basics.Float, a ), Maybe.Maybe (RandomTree.Weighted.Tree a) )"},{"name":"remove","comment":" Removes all instances of the specified element from the `RandomTree.Weighted.Tree`. The result is wrapped in a `Maybe` type to indicate if the tree is empty after removal.\n","type":"a -> RandomTree.Weighted.Tree a -> Maybe.Maybe (RandomTree.Weighted.Tree a)"},{"name":"singleton","comment":" Creates `RandomTree.Weighted.Tree` from a single element and its associated weight.\n","type":"( Basics.Float, a ) -> RandomTree.Weighted.Tree a"},{"name":"take","comment":" Returns a `Random.Generator` that produces n weighted contents selected randomly from the tree. The result includes the remaining tree structure.\n","type":"Basics.Int -> RandomTree.Weighted.Tree a -> Random.Generator ( List.List ( Basics.Float, a ), Maybe.Maybe (RandomTree.Weighted.Tree a) )"},{"name":"toList","comment":" Converts a `RandomTree.Weighted.Tree` into a list of tuples containing the weights and their corresponding contents.\n","type":"RandomTree.Weighted.Tree a -> List.List ( Basics.Float, a )"}],"binops":[]},{"name":"RandomTree.WideFloatWeighted","comment":" This module provides data structure that allows random picking up from a collection of data in _O(log(N))_ time. You can set weight of each element with `WideFloat` from `kudzu-forest/elm-wide-float` package.\n\n\n## Note\n\n`Tree` in this module\n\n  - is not allowed to be empty, so\n      - the return value of function that reduce the number of element(`take`, `delete`, and `filter`) all return `Maybe (Tree a)` just in case all the elements are deleted.\n      - You have to pass at least one element at the creation, so function like `fromList` takes one heading element and tailing list.(similar with `Random.uniform` or `Random.weighted`.)\n  - can not have zero-or-negative-weighted elements. So if you give ones, the weight is automatically converted to `1`. This may be an error prone, but otherwise all things must be wrapped in `Maybe`.\n  - is not a search tree(the elements are not ordered), so the time complexity of `member` and `delete` is _O(N)_.\n  - may be unbalanced when `delete` or `filter` is called, so when I say \"The time complexity is _O(log(N))_\", _N_ denotes the maximal size in the history of the tree so far.\n\n\n# Types\n\n@docs Tree, Weighted, WideFloat\n\n\n# Operation around weighted datum\n\n@docs adjustWeight, adjustContent\n\n\n# Creation\n\n@docs singleton, fromList, fromPairs\n\n\n# Insertion\n\n@docs insert, insertWithRelativeWeight, insertListWithRelativeWeight\n\n\n# Modification\n\n@docs delete, map, filter\n\n\n# Random Pick Up\n\n@docs get, take, replace\n\n\n# Status Checking\n\n@docs count, totalWeight\n\n","unions":[{"name":"Tree","comment":" Type that represents binary tree with weighted elements subjected to random picking up.\n","args":["a"],"cases":[]}],"aliases":[{"name":"Weighted","comment":" Type alias that represents each weighted contents in `Tree`. The probability of being chosen is proportional to its weight.\nThe weight is represented with `WideFloat.WideFloat` type in `kudzu-forest/elm-wide-float` package.\n","args":["a"],"type":"{ weight : WideFloat.WideFloat, content : a }"},{"name":"WideFloat","comment":" Type that represent floating point number with wider range than `Float` in core package. This is introduced for preventing overflow of exponentially changing value.\nPlease hit `elm install kudzu-forest/elm-wide-float` in your terminal.\n","args":[],"type":"WideFloat.WideFloat"}],"values":[{"name":"adjustContent","comment":" Maps content in `Element`.\n","type":"(a -> b) -> RandomTree.WideFloatWeighted.Weighted a -> RandomTree.WideFloatWeighted.Weighted b"},{"name":"adjustWeight","comment":" Returns weighted datum whose weight is multiplied with the given `Float`.\n","type":"Basics.Float -> RandomTree.WideFloatWeighted.Weighted a -> RandomTree.WideFloatWeighted.Weighted a"},{"name":"count","comment":" Returns how many elements the tree has. The time complexity is _O(1)_\n","type":"RandomTree.WideFloatWeighted.Tree a -> Basics.Int"},{"name":"delete","comment":" Removes any number of elements which is the same as the first parameter from the second parameter. The returned value is wrapped in `Maybe`. The time complexity is _O(N)_.\n","type":"a -> RandomTree.WideFloatWeighted.Tree a -> Maybe.Maybe (RandomTree.WideFloatWeighted.Tree a)"},{"name":"filter","comment":" Removes any number of elements which passes the test function given as the first parameter from the second parameter. The returned value is wrapped in `Maybe`.\n","type":"(RandomTree.WideFloatWeighted.WideFloat -> a -> Basics.Bool) -> RandomTree.WideFloatWeighted.Tree a -> Maybe.Maybe (RandomTree.WideFloatWeighted.Tree a)"},{"name":"fromList","comment":" Returns a `Tree` that has all element in given list.Never give this function a negetive-or-zero-weighted element.(If the weight is negative or zero, the weight is automatically converted to 1.)\n","type":"RandomTree.WideFloatWeighted.Weighted a -> List.List (RandomTree.WideFloatWeighted.Weighted a) -> RandomTree.WideFloatWeighted.Tree a"},{"name":"fromPairs","comment":" Creates `Tree` from list of tuples of a `Float` value corresponding to its weight as the first component, and a datum as the second component. Never give this function a negetive-or-zero-weighted element.(If the weight is negative or zero, the weight is automatically converted to 1.)\n","type":"( Basics.Float, a ) -> List.List ( Basics.Float, a ) -> RandomTree.WideFloatWeighted.Tree a"},{"name":"get","comment":" Random generator that generates one of the elements conteined in `Tree` given as parameter. The probability for each elements to be chosen is proportional to its weight. The time complexity is _O(log(N))_.\n","type":"RandomTree.WideFloatWeighted.Tree a -> Random.Generator a"},{"name":"insert","comment":" Inserts a Weighted data to an already-existing `Tree`. Never give this function a negetive-or-zero-weighted element.(If the weight is negative or zero, the weight is automatically converted to 1.)\n","type":"RandomTree.WideFloatWeighted.Weighted a -> RandomTree.WideFloatWeighted.Tree a -> RandomTree.WideFloatWeighted.Tree a"},{"name":"insertListWithRelativeWeight","comment":" Inserts all elements of given list into the tree of second parameter. The first components of the tuple denotes the relative weight(`1` means the whole weight of the original tree).\n","type":"List.List ( Basics.Float, a ) -> RandomTree.WideFloatWeighted.Tree a -> RandomTree.WideFloatWeighted.Tree a"},{"name":"insertWithRelativeWeight","comment":" Inserts an element into the tree. The first parameter denotes the relative weight(`1` means the whole weight of the original tree). The time complexity is _O(log(N))_.\n","type":"Basics.Float -> a -> RandomTree.WideFloatWeighted.Tree a -> RandomTree.WideFloatWeighted.Tree a"},{"name":"map","comment":" Maps all the content of the tree, with the weights unchanged.\n","type":"(a -> b) -> RandomTree.WideFloatWeighted.Tree a -> RandomTree.WideFloatWeighted.Tree b"},{"name":"replace","comment":" Random generator that replaces one weighted data from the tree and generates a pair consisting of the removed data and resultant tree. The time complexity is _O(log(N))_\n","type":"RandomTree.WideFloatWeighted.Weighted a -> RandomTree.WideFloatWeighted.Tree a -> Random.Generator ( RandomTree.WideFloatWeighted.Weighted a, RandomTree.WideFloatWeighted.Tree a )"},{"name":"singleton","comment":" Returns a `Tree` that has only one element. Never give this function a negetive-or-zero-weighted element.(If the weight is negative or zero, the weight is automatically converted to 1.)\n","type":"RandomTree.WideFloatWeighted.Weighted a -> RandomTree.WideFloatWeighted.Tree a"},{"name":"take","comment":" Random generator that generates one of the elements conteined in `Tree`, paired with the rest part of the tree.\nIf the `Tree` has only one element, then `Nothing` is returned as the second component.\nThe time complexity is _O(log(N))_.\n","type":"RandomTree.WideFloatWeighted.Tree a -> Random.Generator ( RandomTree.WideFloatWeighted.Weighted a, Maybe.Maybe (RandomTree.WideFloatWeighted.Tree a) )"},{"name":"totalWeight","comment":" Returns the sum of weight of all the elements in the tree. The time complexity is _O(1)_\n","type":"RandomTree.WideFloatWeighted.Tree a -> RandomTree.WideFloatWeighted.WideFloat"}],"binops":[]}]