<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Okay so I’ve been tweaking the protocols that I’m using. For my own use I’ve ended up with two protocols:</div><div class=""><br class=""></div><div class=""><ul class="MailOutline"><li class=""><b class="">ExtendableCollectionType</b>: Which implements .insert() and .insertContentsOf() methods, as well as a non-binding concept of capacity.</li><li class=""><b class="">RangeRemoveableCollectionType:</b>&nbsp;Which implements most basic removal methods that don’t involve replacing anything (i.e- they don’t include insertions at specific indices). This is therefore safe for self-ordering collections as while insertion can’t support an index (can’t guarantee item will end up where it’s placed), removing them should have no such restrictions that I can see.</li></ul><div class=""><br class=""></div></div><div class="">This effectively leaves RangeReplaceCollectionType with index based insertions, append (insert at end) and range replacement methods. Other proposed changes include removing the initialisers (since these restrict implementations), and possibly changing the .replaceRange() method to accept a sequence rather than a collection as I don’t believe a collection should be required?</div><div class=""><br class=""></div><div class="">Here’s a quick, simplified, example of how everything would look:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><div style="margin: 0px; color: rgb(0, 132, 0);" class="">// Extension of a collection by adding new contents</div><div style="margin: 0px;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">protocol</span> ExtendableCollectionType : <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">CollectionType</span> {</div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> capacity:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Index</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Distance</span> { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">get</span> }</div><div style="margin: 0px; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> insert(element:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span>)</div><div style="margin: 0px; color: rgb(112, 61, 170);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> insertContentsOf&lt;S:</span>SequenceType<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">where</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>S<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Generator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Element<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> == </span>Self<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Generator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Element<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&gt;(elements:</span>S<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><div style="margin: 0px; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> reserveCapacity(minimumCapacity:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Bool</span>)</div><div style="margin: 0px;" class="">}</div><div style="margin: 0px; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>ExtendableCollectionType<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> capacity:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Index</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Distance</span> { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">count</span> }</div><div style="margin: 0px; color: rgb(112, 61, 170);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> insertContentsOf&lt;S:</span>SequenceType<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">where</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>S<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Generator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Element<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> == </span>Self<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Generator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Element<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&gt;(elements:</span>S<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">) {</span></div><div style="margin: 0px;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">for</span> element <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">in</span> elements { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">insert</span>(element) }</div><div style="margin: 0px;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px;" class="">}</div><div style="margin: 0px; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">extension</span> <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ExtendableCollectionType</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">where</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">Self</span>:RangeReplaceableCollectionType {</div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> insert(element:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span>) { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">append</span>(element) }</div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> insertContentsOf&lt;S:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">SequenceType</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">where</span> <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">S</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span> == <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span>&gt;(elements:<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">S</span>) { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">appendContentsOf</span>(elements) }</div><div style="margin: 0px;" class="">}</div><div style="margin: 0px; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; color: rgb(0, 132, 0);" class="">// Removal of specific indices</div><div style="margin: 0px;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">protocol</span> RangeRemoveableCollectionType : <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ExtendableCollectionType</span> {</div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> removeAll(keepCapacity keepCapacity:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Bool</span>)</div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> removeAtIndex(index:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Index</span>) -&gt; <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span></div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> removeRange(subRange:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Range</span>&lt;<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Index</span>&gt;)</div><div style="margin: 0px;" class="">}</div><div style="margin: 0px; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>RangeRemoveableCollectionType<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> removeAll(keepCapacity keepCapacity:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Bool</span>) { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">removeRange</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">startIndex</span> ..&lt; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">endIndex</span>) }</div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> removeFirst() -&gt; <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span>? { … }</div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> removeFirst(n:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Index</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Distance</span>) { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">removeRange</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">startIndex</span> ..&lt; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">startIndex</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">advancedBy</span>(n)) }</div><div style="margin: 0px;" class="">}</div><div style="margin: 0px; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">extension</span> <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">RangeRemoveableCollectionType</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">where</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">Self</span>.Index:BidirectionalIndexType {</div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> removeLast() -&gt; <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span>? { … }</div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> removeLast(n:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Index</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Distance</span>) { <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">removeRange</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">endIndex</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">advancedBy</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">-</span>n) ..&lt; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">endIndex</span>) }</div><div style="margin: 0px;" class="">}</div><div style="margin: 0px; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; color: rgb(0, 132, 0);" class="">// Insertion/replacement at specific indices</div><div style="margin: 0px;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">protocol</span> RangeReplaceableCollectionType : <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">RangeRemoveableCollectionType</span> {</div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> append(element:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span>)</div><div style="margin: 0px; color: rgb(112, 61, 170);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> appendContentsOf&lt;S:</span>SequenceType<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">where</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>S<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Generator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Element<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> == </span>Self<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Generator<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>Element<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&gt;(elements:</span>S<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> insert(element:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span>, atIndex:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Index</span>)</div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> insertContentsOf&lt;S:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">SequenceType</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">where</span> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">S</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span> == <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span>&gt;(elements:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">S</span>, atIndex:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Index</span>)</div><div style="margin: 0px;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">mutating</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> replaceRange&lt;S:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">SequenceType</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">where</span> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">S</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span> == <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Generator</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span>&gt;(subRange:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Range</span>&lt;<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Index</span>&gt;, with elements:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">S</span>)</div><div style="margin: 0px;" class="">}</div></div></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px;" class="">This is just to give an idea, there may be some accidental omissions and some stuff is simplified or omitted on purpose, but it hopefully shows the separation and structure that I’m aiming for.</div><div style="margin: 0px;" class=""><br class=""></div><div style="margin: 0px;" class="">I was originally going to put all of the RangeRemovableCollectionType methods into ExtendableCollectionType, however that would mean tying the ability to add and to remove together, which may still be limiting; a collection could for example be designed to be consumed internally, or even to just expire its own contents (e.g- a cache type) so may not wish to externally expose methods that would remove elements.</div><div style="margin: 0px;" class=""><br class=""></div><div style="margin: 0px;" class="">Also, naming is absolutely up for debate too, all feedback appreciated!</div><div style="margin: 0px;" class=""><br class=""></div><div style="margin: 0px;" class="">P.S- I know that naming conventions are currently up for debate, so I’m just sticking with the way things are right now for simplicity, obviously everything would be tweaked to match whatever decision is made for whichever version this ends up in =)</div><br class=""><div><blockquote type="cite" class=""><div class="">On 29 Feb 2016, at 21:16, Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On Mon, Feb 29, 2016 at 1:13 PM, Haravikk &lt;</span><a href="mailto:swift-evolution@haravikk.me" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@haravikk.me</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">&gt; wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="">On 29 Feb 2016, at 11:11, Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>&gt; wrote:<br class=""><br class="">On Mon, Feb 29, 2016 at 2:54 AM, Haravikk &lt;<a href="mailto:swift-evolution@haravikk.me" class="">swift-evolution@haravikk.me</a>&gt;<br class="">wrote:<br class=""><br class="">How would you decide equality? &nbsp;You would have two collections, one on<br class="">the left, and one on the right, and each of those has a different<br class="">concept of equality via the stored 'isOrderedBefore' closure.<br class=""><br class=""><br class="">To me two collections are equal so long as their contents are the same, and<br class="">in the same order. In other words the actual closure isn’t necessary to the<br class="">comparison, though obviously it will affect it, since elements stored in<br class="">ascending numeric order clearly won’t match the same elements in descending<br class="">numeric order.<br class=""><br class="">I'm not opposed to adding a new protocol. &nbsp;What seems strange to me is<br class="">that you are describing various collections that clearly can't<br class="">implement RangeReplaceableCollection, and trying to weaken protocol's<br class="">guarantees so that they can.<br class=""><br class=""><br class="">I’m not trying to weaken its guarantees; the only thing directly affecting<br class="">RangeReplaceableCollectionType would be removing the initialisers, as I<br class="">don’t think they’re necessary to implementing that type (though of course I<br class="">welcome any description as to why they may be necessary).<br class=""><br class="">Otherwise a new protocol is exactly what I’m interested in; you mentioned an<br class="">ExpandableCollectionType, which I think is a start, though it should<br class="">probably have add() and addContentsOf()<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Set calls this operation 'insert'.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">methods rather than appends (this<br class="">way they place no guarantees on where elements will go, only that they are<br class="">added). While the add() method would be a synonym of append() for arrays, it<br class="">would be useful for aligning with Set I think.<br class=""><br class="">Moving the removeRange() and related methods (removeAtIndex etc.) would take<br class="">them away from RangeReplaceableCollectionType (it should extend whatever new<br class="">protocol is added), but the idea is to separate the concept of removing<br class="">things by index, and replacing them/performing insertions.<br class=""><br class="">Basically I’d like to tweak the protocols such that a generic collection can<br class="">be expanded, and its elements accessed in an order, but that order may be<br class="">defined by the type itself; to me, inserting a value directly at a specific<br class="">index is a more specialist type.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Sound like a plan. &nbsp;Please make sure to design the protocol in such a</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">way that there are useful generic algorithms that can be written over</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">such a protocol.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Dmitri</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">--<span class="Apple-converted-space">&nbsp;</span></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">main(i,j){for(i=2;;i++){for(j=2;j&lt;i;j++){if(!(i%j)){j=0;break;}}if</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">(j){printf("%d\n",i);}}} /*Dmitri Gribenko &lt;</span><a href="mailto:gribozavr@gmail.com" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">gribozavr@gmail.com</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">&gt;*/</span></div></blockquote></div><br class=""></body></html>