Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dict: Add divideAndConquer helper. #1063

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

showell
Copy link

@showell showell commented Nov 12, 2019

This function will allow folks to do O(logN)
traversals in some situations where the opaque
nature of Dict currently would prevent those
optimizations.

An example use case would be that you only want
to render the visible portion of a line chart
whose values were stored in a Dict.

As I mention in the docs, it's for advanced users.

Example usage:

example =
    [ ( 5, "fred" )
    , ( 6, "joe" )
    , ( 7, "mary" )
    , ( 8, "ann" )
    , ( 9, "bob" )
    , ( 10, "carl" )
    ]
        |> Dict.fromList

_ =
    Debug.log "hello" (Dict.divideAndConquer example)

yo =
    Debug.log "hello" (Dict.divideAndConquer Dict.empty)
This function will allow folks to do O(logN)
traversals in some situations where the opaque
nature of Dict currently would prevent those
optimizations.

An example use case would be that you only want
to render the visible portion of a line chart
whose values were stored in a Dict.

As I mention in the docs, it's for advanced users.

Example usage:

    example =
        [ ( 5, "fred" )
        , ( 6, "joe" )
        , ( 7, "mary" )
        , ( 8, "ann" )
        , ( 9, "bob" )
        , ( 10, "carl" )
        ]
            |> Dict.fromList

    _ =
        Debug.log "hello" (Dict.divideAndConquer example)

    yo =
        Debug.log "hello" (Dict.divideAndConquer Dict.empty)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant