Iesi.Collections の最新バージョンでは、Iesi.Collections.Generic.ISet がありません。次の 3 つの選択肢があるようです。
- LinkedHashSet
- 読み取り専用セット
- 同期セット
Iesi.Collections.Generic.ReadOnlySet が ISet に最も近いようで、ドキュメントには次のように記載されています。
... although it's advertised as immutable it really isn't.
Anyone with access to the wrapped set can still change the set.
ReadOnlySet が ISet の最良の代替品であるように思われますか? 現在、実装はパブリック メソッドを介してセットにアイテムを追加しているため、最適なようです。代替手段 (IList、バッグ?) は、より多くのリソースを必要とするか、またはそれほど迅速/効率的ではないようです)? より良い代替手段はありますか?(リストには重複があってはなりません。これは手動で確認できます)
私は次のようなことをします:
public virtual ISet<MyClass> MyClass
{
get { return this.myClass }
}
public virtual void AddItem(MyClass item)
{
... // Null checks and initialize ISet if null
myClass.Add(item)
}
基本的には代替手段に要約されますが、速度などのマイナスの結果のない代替手段はありますか?