From 9ec3f70a5a194e2c1d590b265871c3e775844b0c Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Fri, 10 Apr 2020 20:39:34 +0200 Subject: [PATCH 1/4] Add initial spec of IndexPath class --- active/IndexPath/IndexPath.md | 78 +++++++++++++++++++++ active/IndexPath/sample-tree-selection.png | Bin 0 -> 12376 bytes 2 files changed, 78 insertions(+) create mode 100644 active/IndexPath/IndexPath.md create mode 100644 active/IndexPath/sample-tree-selection.png diff --git a/active/IndexPath/IndexPath.md b/active/IndexPath/IndexPath.md new file mode 100644 index 000000000..38a541931 --- /dev/null +++ b/active/IndexPath/IndexPath.md @@ -0,0 +1,78 @@ +# Background + +To easily track selection in nested collections, we need an object that we can use to uniquely identify an item in nested collections. +This can be done with the IndexPath. + +# Description + +The `IndexPath` class provides indexing of nested collections, for example for a TreeView. + + +# Examples + +In the tree below, using the following IndexPath +```c# + +var indexPath = IndexPath.CreateFromIndices(new List{ 1, 0, 3 }); + +``` + would select the item "Kitchen cabinet style", since it is in the second group of first nesting level, first group in the second level of nesting and is the fourth element in the last nesting level. + +![Sample tree selection](./sample-tree-selection.png) + + +Comparing two `IndexPath` objects can be done using the `CompareTo` function: + +```c# +var baseIndexPath = IndexPath.CreateFromIndices(new List { 1, 4, 2 }); + +var shorterPath = IndexPath.CreateFrom(2, 0); + +// Since shorterPath takes second element of first nesting, it is "greater" than baseIndexPath +Assert.AreEqual(1, shorterPath.CompareTo(baseIndexPath)); + + +var sameLengthPath = IndexPath.CreateFromIndices(new List { 1, 0, 1 }); + +// Since sameLength path enters before baseIndexPath on the second level, it is smaller than basePath +Assert.AreEqual(-1, sameLengthPath.CompareTo(baseIndexPath)); + + +var baseIndexPathCopy = IndexPath.CreateFromIndices(new List { 1, 4, 2 }); +// Those two are the same, and thus CompareTo returns 0 +Assert.AreEqual(0, baseIndexPathCopy.CompareTo(baseIndexPath)); +``` + +# API Notes + +| Function | Description | +|-|-| +|Int32 GetSize()| Returns the size of the IndexPath. | +|Int32 GetAt(Int32 index)| Returns the index for a given nesting level. | +| Int32 CompareTo(IndexPath other)| Compares the IndexPath to a different IndexPath. If the other IndexPath is behind the current IndexPath, the method returns -1, if the other IndexPath is before the current IndexPath it returns 1. In case of equality this method returns 0. | +| static IndexPath CreateFrom(Int32 index) | Creates an IndexPath that only consists of the index provided. | +| static IndexPath CreateFrom(Int32 groupIndex, Int32 itemIndex) | Creates an IndexPath with the given group index and item index for the given group. | +| static IndexPath CreateFromIndices(IVector indices) | Creates an IndexPath from the given list of integers. + +# API Details + +```c++ +[WUXC_VERSION_MUXONLY] +[webhosthidden] +runtimeclass IndexPath : Windows.Foundation.IStringable +{ + Int32 GetSize(); + Int32 GetAt(Int32 index); + Int32 CompareTo(IndexPath other); + + [default_overload] [method_name("CreateFrom")] + static IndexPath CreateFrom(Int32 index); + [method_name("CreateFromGroupAndItemIndex")] + static IndexPath CreateFrom(Int32 groupIndex, Int32 itemIndex); + static IndexPath CreateFromIndices(Windows.Foundation.Collections.IVector indices); +} +``` + +# Appendix + +Currently we use an Vector to store those indices. Since we don't have any operations that would modify the size of an IndexPath, that is how many nesting levels it works with, shouldn'twe switch to an array to increase performance? \ No newline at end of file diff --git a/active/IndexPath/sample-tree-selection.png b/active/IndexPath/sample-tree-selection.png new file mode 100644 index 0000000000000000000000000000000000000000..9a8c484540b4f733662134907d0a62fb03beed1a GIT binary patch literal 12376 zcmd6tcT`i0w(f%s#e!}THAr!@bqfes0FjPpEHn`a9Ymyr5D+1t!6YIeDgv?f6{o;kQS3n>cIPjITc@yxHEBn=YfNwGpSI(aSkva}c053KKTH0EI zKozN5SA91EueaQ|;1&S_?P&h_CDR&)zYYTFp1OF}(&?7>)S$Wjflr(dBa4`Odmiq- zaCDcenqh3jujN+18veTBx`F=Cc;mwz*Wni|*PXH6ITrwb@XA;w_JCTN#hH7HyI(|4 z7v#*HJlE;7$>w;2b#V6})60uFIpF2h+@>3l-QL+Kl^%5HK9JUj*+~U5X z`f1BQKZ8sY7<9tIb-l%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j|^@m&!oUolEzCm8Y+Od<-4z92xNy%Jk`E;}&Aa?v_ulOK1Y5 zx#HS2!@DK`&|D{XfNfC*rN(AvBs=)FZQFWn0r|b z;hiGaC@gr;?~4nd#e9Ll?Wlp!ApnrFHV;1nJqwAlcvq68!uY*L(@7lX}mO%r+B)CQ**UmF&lKg?Y2QJv{e6e=ae(?^-whbEh#ZBt&6t zr4w7)%EO)cNV7b6-Kp5%xxdK)oI;z1oW} zn{=k{+Gz80HHfaIJmpsX5JHje@gj@OE&#sYes(BxD?IrX5U2r{!Jy8vyXK0!Z~OPu ziwt0cOXt<$F^2kuyDBmAQK5yyaVgH`k&ic$u@@l&I)kW37jd zz#R|!({HE7h5}e=;hW!Bp-bb>CtCCm~Nsc zlu!R6{=-4N=LEO}Mt{G~OZ~j0Cbur2j4-5CgY#1`09$fuKCAp93@Sb68-P8Y-?GT% z-dhBWW1S5zaEZyenq70*DJBeqpo+XIBTA=iW#AaT4y?~r_=AJ*5(+1z8mq_|M#@@fC+6B&?NMNrXbn%?sS<;!S_qKyx zs^ewUA~pazE+uc%-9LBrf}Whd2iQjEFR!=wu{jv@@qp!j$3Y}z=l8;&pcK9xbi@0n nSp{d4T8QqpabVCa?6^?oAKeJ0V0rB<`+ Date: Sun, 12 Apr 2020 14:49:39 +0200 Subject: [PATCH 2/4] Update spec --- active/IndexPath/IndexPath.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/active/IndexPath/IndexPath.md b/active/IndexPath/IndexPath.md index 38a541931..fd82d0b04 100644 --- a/active/IndexPath/IndexPath.md +++ b/active/IndexPath/IndexPath.md @@ -5,8 +5,7 @@ This can be done with the IndexPath. # Description -The `IndexPath` class provides indexing of nested collections, for example for a TreeView. - +The `IndexPath` class provides indexing of nested collections, for example in a TreeView. # Examples @@ -20,7 +19,26 @@ var indexPath = IndexPath.CreateFromIndices(new List{ 1, 0, 3 }); ![Sample tree selection](./sample-tree-selection.png) +### Creating IndexPath objects +New IndexPaths objects can be created using the static `IndexPath.CreateFrom` and `IndexPath.CreateFromIndices` methods: + +```csharp + +// Points to the third element in a flat collection +var simplePath = IndexPath.CreateFrom(2); + +// This is the same IndexPath as "simplePath" +var simplePathIndices = IndexPath.CreateFromIndices(new List(){ 2 }); + +// This will point to the third child of the second element in a nested collection +var groupedPath = IndexPath.CreateFrom(1,2); + +// The following IndexPath is equivalent to "groupedPath" +var groupedPathIndices = IndexPath.CreateFromIndices(new List(){ 1, 2 }); + +``` +### Comparing two IndexPaths Comparing two `IndexPath` objects can be done using the `CompareTo` function: ```c# @@ -75,4 +93,4 @@ runtimeclass IndexPath : Windows.Foundation.IStringable # Appendix -Currently we use an Vector to store those indices. Since we don't have any operations that would modify the size of an IndexPath, that is how many nesting levels it works with, shouldn'twe switch to an array to increase performance? \ No newline at end of file +Currently we use a `Vector` to store those indices. Since we don't have any operations that would modify the size of an IndexPath, that is how many nesting levels it works with, shouldn't we switch to an array to increase performance? From 5c18e6cfcdf2e07d2db868e671ded29da82d4c1e Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Mon, 13 Apr 2020 21:02:32 +0200 Subject: [PATCH 3/4] Update wording --- active/IndexPath/IndexPath.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/active/IndexPath/IndexPath.md b/active/IndexPath/IndexPath.md index fd82d0b04..1bd7efb9f 100644 --- a/active/IndexPath/IndexPath.md +++ b/active/IndexPath/IndexPath.md @@ -65,8 +65,8 @@ Assert.AreEqual(0, baseIndexPathCopy.CompareTo(baseIndexPath)); | Function | Description | |-|-| -|Int32 GetSize()| Returns the size of the IndexPath. | -|Int32 GetAt(Int32 index)| Returns the index for a given nesting level. | +|Int32 GetSize()| Returns the number of nesting levels this IndexPath addresses. | +|Int32 GetAt(Int32 index)| Returns the index for the item in a given nesting level. | | Int32 CompareTo(IndexPath other)| Compares the IndexPath to a different IndexPath. If the other IndexPath is behind the current IndexPath, the method returns -1, if the other IndexPath is before the current IndexPath it returns 1. In case of equality this method returns 0. | | static IndexPath CreateFrom(Int32 index) | Creates an IndexPath that only consists of the index provided. | | static IndexPath CreateFrom(Int32 groupIndex, Int32 itemIndex) | Creates an IndexPath with the given group index and item index for the given group. | From 60a8c2a96e19e3291f1228c7d30278b98201a1eb Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Wed, 15 Apr 2020 13:38:21 +0200 Subject: [PATCH 4/4] CR feedback --- active/IndexPath/IndexPath.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/active/IndexPath/IndexPath.md b/active/IndexPath/IndexPath.md index 1bd7efb9f..cdb330cd4 100644 --- a/active/IndexPath/IndexPath.md +++ b/active/IndexPath/IndexPath.md @@ -31,7 +31,7 @@ var simplePath = IndexPath.CreateFrom(2); var simplePathIndices = IndexPath.CreateFromIndices(new List(){ 2 }); // This will point to the third child of the second element in a nested collection -var groupedPath = IndexPath.CreateFrom(1,2); +var groupedPath = IndexPath.CreateFromGroupAndItemIndex(1,2); // The following IndexPath is equivalent to "groupedPath" var groupedPathIndices = IndexPath.CreateFromIndices(new List(){ 1, 2 }); @@ -44,7 +44,7 @@ Comparing two `IndexPath` objects can be done using the `CompareTo` function: ```c# var baseIndexPath = IndexPath.CreateFromIndices(new List { 1, 4, 2 }); -var shorterPath = IndexPath.CreateFrom(2, 0); +var shorterPath = IndexPath.CreateFromGroupAndItemIndex(2, 0); // Since shorterPath takes second element of first nesting, it is "greater" than baseIndexPath Assert.AreEqual(1, shorterPath.CompareTo(baseIndexPath)); @@ -69,7 +69,7 @@ Assert.AreEqual(0, baseIndexPathCopy.CompareTo(baseIndexPath)); |Int32 GetAt(Int32 index)| Returns the index for the item in a given nesting level. | | Int32 CompareTo(IndexPath other)| Compares the IndexPath to a different IndexPath. If the other IndexPath is behind the current IndexPath, the method returns -1, if the other IndexPath is before the current IndexPath it returns 1. In case of equality this method returns 0. | | static IndexPath CreateFrom(Int32 index) | Creates an IndexPath that only consists of the index provided. | -| static IndexPath CreateFrom(Int32 groupIndex, Int32 itemIndex) | Creates an IndexPath with the given group index and item index for the given group. | +| static IndexPath CreateFromGroupAndItemIndex(Int32 groupIndex, Int32 itemIndex) | Creates an IndexPath with the given group index and item index for the given group. | | static IndexPath CreateFromIndices(IVector indices) | Creates an IndexPath from the given list of integers. # API Details @@ -83,10 +83,8 @@ runtimeclass IndexPath : Windows.Foundation.IStringable Int32 GetAt(Int32 index); Int32 CompareTo(IndexPath other); - [default_overload] [method_name("CreateFrom")] static IndexPath CreateFrom(Int32 index); - [method_name("CreateFromGroupAndItemIndex")] - static IndexPath CreateFrom(Int32 groupIndex, Int32 itemIndex); + static IndexPath CreateFromGroupAndItemIndex(Int32 groupIndex, Int32 itemIndex); static IndexPath CreateFromIndices(Windows.Foundation.Collections.IVector indices); } ```