#59 SharedList

クローズ
4 年 前ranides によって開かれました · 3 コメント
ranides4 年 前 にコメントしました

We should have a list wrapper which offers access to internal/source list and allows exposing its' content to public consumers in a safe way.

"Safe" means, that every time returned public list must behave like defensive, shallow copy.

Because of performance reasons, we wont create shallow copies over and over again, but return protected views.

We should have a list wrapper which offers access to internal/source list and allows exposing its' content to public consumers in a safe way. "Safe" means, that every time returned public list must __behave__ like defensive, shallow copy. Because of performance reasons, we wont create shallow copies over and over again, but return protected views.
ranides4 年 前 にコメントしました
オーナー

class SharedList will have fields:

  1. source: List
  2. view: PublicList
  3. data: PrivateList

The source one must be hidden from everyone.

PublicList will delegate read operations to "source" or "copy of source". That means reference to target list can be replaced by new ArrayList(source) at any time. After replacement, SharedList will clear their (2) field. From this moment, PublicList will be detached, almost ordinary, independent list adapter.

Replacement will be triggered by any write operation on PublicList or PrivateList. PrivateList is simpler. It will always delegate all operations to source, but write operations will work like "just listeners".

Please note, that it is pointless of creating SharedList from source which will be accessible from outside world, because SharedList won't have any way to observe change of data and detach PublicList correctly.

class SharedList will have fields: 1. source: `List` 2. view: `PublicList` 3. data: `PrivateList` The source one must be hidden from everyone. PublicList will delegate read operations to "source" or "copy of source". That means reference to target list can be replaced by new ArrayList(source) at any time. After replacement, SharedList will clear their (2) field. From this moment, PublicList will be detached, almost ordinary, independent list adapter. Replacement will be triggered by any write operation on PublicList or PrivateList. PrivateList is simpler. It will always delegate all operations to source, but write operations will work like "just listeners". Please note, that it is pointless of creating SharedList from source which will be accessible from outside world, because SharedList won't have any way to observe change of data and detach PublicList correctly.
ranides4 年 前 にコメントしました
オーナー

Maybe whole functionality is pointless and we should accept the fact, that we can't control changes inside source? We should just implement something different, called: "FastCopy" which will detach on their own, but it won't detach eralier.

I mean: FastCopy will tell to everyone: "I am just a view, until you try to modify me"

Maybe whole functionality is pointless and we should accept the fact, that we can't control changes inside `source`? We should just implement something different, called: "FastCopy" which will detach on their own, but it won't detach eralier. I mean: FastCopy will tell to everyone: _"I am just a view, until you try to modify me"_
ranides 4 年 前 に閉じられました
ranides4 年 前 にコメントしました
オーナー

CopyList done

CopyList done
会話に参加するには サインイン してください。
マイルストーンなし
担当者なし
1 参加者
読み込み中…
キャンセル
保存
まだコンテンツがありません