(Feature suggestion) SortedMultiSet

オープン
#779 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
julia
領域
data

調査の方向性

既存の SortedSet と SortedMultiDict の実装および API を確認することから始めます。SortedMultiSet が重複する比較キー、効率的な挿入・削除・検索、値による削除をどのように扱うべきかを定義してください。issue ではファイルやテストが特定されていないため、完了基準については maintainer の合意が必要になります。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Julia
スター
747
フォーク
261
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

JuliaCollections/DataStructures.jl のほかの issue

JuliaCollections/DataStructures.jl の issue をすべて見る

似ている issue

Julia の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。