Skip to content

Commit

Permalink
Allow ParallelSort on lists without IsDenseList
Browse files Browse the repository at this point in the history
This was already allowed in Sort. While Sort and ParallelSort
both fail with an error if given a non-dense lists, there can
exists lists which are dense but do not have the filter IsDenseList
  • Loading branch information
ChrisJefferson committed Nov 9, 2018
1 parent 3d142c1 commit 6cd1646
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
8 changes: 4 additions & 4 deletions lib/list.gd
Original file line number Diff line number Diff line change
Expand Up @@ -1786,14 +1786,14 @@ DeclareGlobalFunction( "PermListList" );
## <#/GAPDoc>
##
DeclareOperation( "SortParallel",
[ IsDenseList and IsMutable, IsDenseList and IsMutable ] );
[ IsList and IsMutable, IsList and IsMutable ] );
DeclareOperation( "SortParallel",
[ IsDenseList and IsMutable, IsDenseList and IsMutable, IsFunction ] );
[ IsList and IsMutable, IsList and IsMutable, IsFunction ] );

DeclareOperation( "StableSortParallel",
[ IsDenseList and IsMutable, IsDenseList and IsMutable ] );
[ IsList and IsMutable, IsList and IsMutable ] );
DeclareOperation( "StableSortParallel",
[ IsDenseList and IsMutable, IsDenseList and IsMutable, IsFunction ] );
[ IsList and IsMutable, IsList and IsMutable, IsFunction ] );


#############################################################################
Expand Down
24 changes: 12 additions & 12 deletions lib/list.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2460,15 +2460,15 @@ InstallMethod( SortingPerm,
#M SortParallel( <list>, <list2> ) . . . . . . . sort two lists in parallel
##
InstallMethod( SortParallel,
"for two dense and mutable lists",
[ IsDenseList and IsMutable,
IsDenseList and IsMutable ],
"for two mutable lists",
[ IsList and IsMutable,
IsList and IsMutable ],
SORT_PARA_LIST );

InstallMethod( StableSortParallel,
"for two dense and mutable lists",
[ IsDenseList and IsMutable,
IsDenseList and IsMutable ],
"for two mutable lists",
[ IsList and IsMutable,
IsList and IsMutable ],
STABLE_SORT_PARA_LIST );

#############################################################################
Expand All @@ -2494,16 +2494,16 @@ InstallMethod( StableSortParallel,
#M SortParallel( <list>, <list2>, <func> )
##
InstallMethod( SortParallel,
"for two dense and mutable lists, and function",
[ IsDenseList and IsMutable,
IsDenseList and IsMutable,
"for mutable lists, and function",
[ IsList and IsMutable,
IsList and IsMutable,
IsFunction ],
SORT_PARA_LIST_COMP );

InstallMethod( StableSortParallel,
"for two dense and mutable lists, and function",
[ IsDenseList and IsMutable,
IsDenseList and IsMutable,
"for two mutable lists, and function",
[ IsList and IsMutable,
IsList and IsMutable,
IsFunction ],
STABLE_SORT_PARA_LIST_COMP );

Expand Down
13 changes: 13 additions & 0 deletions tst/testinstall/objlist.tst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ gap> IsSet(a);
true
gap> x;
[ 2, 10, "cheese" ]
gap> SortBy(a, {z} -> z);
gap> a;
[ 2, 10, "cheese" ]
gap> SortParallel([3,2,1],a);
gap> a;
[ "cheese", 10, 2 ]
gap> l := [1,2,3];
[ 1, 2, 3 ]
gap> SortParallel(a,l);
gap> a;
[ 2, 10, "cheese" ]
gap> l;
[ 3, 2, 1 ]
gap> Unbind(x[2]);
gap> a;
[ 2,, "cheese" ]
Expand Down

0 comments on commit 6cd1646

Please sign in to comment.