Open sl-service-account opened 2 years ago
Lucia Nightfire commented at 2021-12-08T00:07:07Z, updated at 2021-12-08T00:51:17Z
I would make keyindex the last input in ListSortStrided() for contingency's sake.
JIRAUSER333921 commented at 2021-12-08T05:39:51Z
I would like to see sorting by multiple elements of the stride.
Ex. Sort by first element of the stride, but if two strides have an equal first element, sort by the second element.
An example where that's useful is in keeping track of racers on a racetrack; both the laps completed and the progress on the current lap determine who's in first place.
Profaitchikenz Haiku commented at 2021-12-08T16:28:45Z, updated at 2021-12-08T16:29:24Z
What would be the feasibility of both removing a vertical slice completely from withing a strided list and adding a vertical slice into a position within a strided list, thus generating a new strided list with a different size stride?
Aura Linden commented at 2023-02-14T18:26:13Z
llList2ListSlice and llListSortStrided implemented as described. llListFindStrided took a slightly different implementation. SRV-43 for details.
Basic test scripts provided in additional comments.
Aura Linden commented at 2023-02-14T18:27:34Z
//llList2ListSlice minimum test.
output( list src, integer stride, integer keyindex ) { string outstring = "---- column: " + (string)keyindex + "---- stride " + (string)stride + "\n";
outstring = outstring + llDumpList2String( src, " " ); llOwnerSay(outstring); }
slicer( list src, integer start, integer end, integer stride, integer keyindex ) { list sliced = llList2ListSlice( src, start, end, stride, keyindex); output( sliced, stride, keyindex ); }
//llList2ListSlice( src, start, end, stride, index );
default { state_entry() { llSay(0, "llListSortStrided test"); }
touch_start(integer total_number) { list biglist = [ 4, "a", "A", 5, "e", "E", 2, "d", "D", 8, "h", "H", 3, "b", "B", 6, "f", "F", 1, "c", "C", 7, "g", "G" ];
slicer( biglist, 0, -1, 6, 0 ); slicer( biglist, 0, -1, 3, 0 ); slicer( biglist, 3, -1, 6, 0 ); slicer( biglist, 3, -1, 6, 2 ); } }
Aura Linden commented at 2023-02-14T18:28:31Z
//llListSortStrided minimal test
output( list src, string header, integer stride ) { //Display the array split by stride. integer length = llGetListLength(src); integer i; integer j;
string outstring = "---" + header + "--- stride " + (string)stride + "\n";
for(i=0; i < length; i += stride)
{
j = i+stride;
if (j>length)
{
j = length;
}
j--;
outstring = outstring + llDumpList2String( llList2List(src,i,j), " ") + "\n"; } llOwnerSay(outstring); }
baseline( list src, integer stride, integer ascending ) { //llListSort is llListSortStrided keyed on the 0th element. list result = llListSort(src, stride, ascending); output( result, "Baseline", stride); }
strider( list src, integer stride, integer keyindex, integer ascending ) { list sliced = llListSortStrided( src, stride, keyindex, TRUE); output( sliced, "Sorted on " + (string) keyindex, stride ); }
default { state_entry() { llSay(0, "llListSortStrided test"); }
touch_start(integer total_number) { list biglist = [ 4, "a", "A", 5, "E", "e", 2, "d", "D", 8, "H", "h", 3, "b", "B", 6, "F", "f", 1, "c", "C", 7, "G", "g" ];
baseline( biglist, 6, TRUE ); strider( biglist, 6, 0, TRUE ); baseline( biglist, 3, TRUE ); strider( biglist, 3, 0, TRUE ); strider( biglist, 3, 0, TRUE ); } }
How would you like the feature to work?
The only data structure available in LSL is the list. Working with these can be cumbersome.
I propose two new LSL functions:
Function: list llList2ListSlice( list src, integer start, integer end, integer stride, integer index );
Returns a list that is a vertical slice of a strided list. This function constructs a new list which in the index'th item (0 based) in each stride.
integer index - the item in the stride to select.
This function supports Strided Lists.
Function: list llListSortStrided( list src, integer stride, integer keyindex, integer ascending );
Returns a list that is src sorted by the entry keyindex in each stride.
integer ascending – if TRUE then the sort order is ascending, otherwise the order is descending.
This function supports Strided Lists.
Function: integer llListFindListStrided( list src, list test, integer stride, integer keyindex );
Returns the integer index of the beginning of the first stride containing the test value at the keyindex within the stride.
integer keyindex - The index within each stride to consider
If test is not found in src, -1 is returned. The index of the first entry in the list is 0 If test is found at the last index in src the positive index is returned (5th entry of 5 returns 4).
Why is this feature important to you? How would it benefit the community?
Ease of use for strided lists in LSL.
Links
Duplicates
Original Jira Fields
| Field | Value | | ------------- | ------------- | | Issue | BUG-231545 | | Summary | New LSL Functions llList2ListSlice, llSortListStrided, and llListFindListStrided | | Type | New Feature Request | | Priority | Unset | | Status | Accepted | | Resolution | Accepted | | Reporter | Rider Linden (rider.linden) | | Created at | 2021-12-07T20:41:28Z | | Updated at | 2023-02-14T18:28:30Z | ``` { 'Build Id': 'unset', 'Business Unit': ['Platform'], 'Date of First Response': '2021-12-07T18:07:07.055-0600', 'How would you like the feature to work?': 'The only data structure available in LSL is the list. Working with these can be cumbersome. \r\n\r\nI propose two new LSL functions:\r\n\r\n\r\nFunction: list llList2ListStrided( list src, integer start, integer end, integer stride );\r\n198\tFunction ID\r\n0.0\tForced Delay\r\n10.0\tEnergy\r\nReturns a list of all the entries in the strided list whose index is a multiple of stride in the range start to end.\r\n• list\tsrc\t\t\t\r\n• integer\tstart\t–\tstart index\t\r\n• integer\tend\t–\tend index\t\r\n• integer\tstride\t–\tnumber of entries per stride, if less than 1 it is assumed to be 1\t\r\nThis function supports Strided Lists.', 'ReOpened Count': 0.0, 'Severity': 'Unset', 'Target Viewer Version': 'viewer-development', 'Why is this feature important to you? How would it benefit the community?': 'Ease of use for strided lists in LSL.', } ```