(Feature suggestion) SortedMultiSet

Abierto
#779 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
30/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
julia
Área
data

Línea de trabajo

Comience revisando las implementaciones existentes de SortedSet y SortedMultiDict y sus APIs. Defina cómo debe manejar un SortedMultiSet las claves de comparación duplicadas, la inserción/eliminación/búsqueda eficientes y la eliminación por valor; el issue no identifica archivos ni pruebas, por lo que los criterios de finalización tendrían que acordarse con los maintainers.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

I think that this package is missing a SortedMultiSet type. As an example, let's say we want to collect a list of persons, sorted by age, as stored in an ages dictionary:

ages = Dict(:bob => 1, :sam => 2, :joe => 1)

and perform efficient insertions/deletions and searching on this list. My first reflex is using a SortedSet for this; however: SortedSet(keys(ages), Base.Order.By(x->ages[x])) merges the keys :bob: and :joe. (*)

There are two ways to work around this limitation right now:

  1. SortedSet((age, person) for (person, age) in ages);
  2. SortedMultiDict(age => person for (person, age) in ages).

However, both of them are somewhat memory-inefficient (they store information equivalent to a full copy of the ages database, as well as quite cumbersome to use (neither implementation allows a simple delete!(set, :bob) call). The second inconvenient may be fixed by writing a simple wrapper over either type (possibly the SortedMultiDict, which is somewhat more efficient), but the first one cannot be fixed except by writing a new structure.

(Also, keep in mind that the example I gave here is of course much simplified. In particular, the comparison values are numbers, and thus quite compact in memory. There could probably be some use cases where the comparison keys are big data structures, hence the fact that we don't want to copy all of them).

(*) in my view this is simply a bad design choice in the definition of SortedSet, because only equal values should be merged, i.e. a set should be allowed to be sorted according to a preorder, but it is likely much too late to change this.

Lenguaje dominante
Julia
Estrellas
747
Forks
261
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de JuliaCollections/DataStructures.jl

Todos los issues de JuliaCollections/DataStructures.jl

Issues similares

Más issues de Julia

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.