Skip to content

Commit

Permalink
Remove PositionFirstComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Sep 15, 2018
1 parent 6a81396 commit 2f6365a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 113 deletions.
82 changes: 0 additions & 82 deletions lib/obsolete.gi
Original file line number Diff line number Diff line change
Expand Up @@ -795,88 +795,6 @@ end);
#


#############################################################################
##
#M PositionFirstComponent( <list>, <obj> ) . . . . . . various
##
## kernel method will TRY_NEXT if any of the sublists are not
## plain lists.
##
## Note that we use PositionSorted rather than Position semantics
##

## This is deprecate because the following three methods each
## compute differen things:
## The first and third both use binary search, but one aborts
## early on the first entry with first component equal to obj,
## while the other aborts late, thus always finding the first
## matching entry. Only the latter behavior matches PositionSorted
## semantics.
##
## The second method on the other hand performs a linear search
## from the start. This means that it also does not conform to
## PositioSorted semantics (not even if the input list happens
## to be sorted). For example, if an entry is not
## found, it returns Length(list)+1, not the position it should
## be inserted to ensure the list stays sorted.
##
## Fixing this could have broken private third-party code.
## Since this operations is rather peculiar and can be replaced
## by PositionSorted(list, [obj]), it was deemed
## simples to declare it obsolete.

# InstallMethod( PositionFirstComponent,"for dense plain list", true,
# [ IsDenseList and IsSortedList and IsPlistRep, IsObject ], 0,
# function ( list, obj )
# Info( InfoObsolete, 1,
# "the operation `PositionFirstComponent' is not supported anymore" );
# return POSITION_FIRST_COMPONENT_SORTED(list, obj);
# end);
#
#
# InstallMethod( PositionFirstComponent,"for dense list", true,
# [ IsDenseList, IsObject ], 0,
# function ( list, obj )
# local i;
# Info( InfoObsolete, 1,
# "the operation `PositionFirstComponent' is not supported anymore" );
# i:=1;
# while i<=Length(list) do
# if list[i][1]=obj then
# return i;
# fi;
# i:=i+1;
# od;
# return i;
# end);
#
# InstallMethod( PositionFirstComponent,"for sorted list", true,
# [ IsSSortedList, IsObject ], 0,
# function ( list, obj )
# local lo,up,s;
# Info( InfoObsolete, 1,
# "the operation `PositionFirstComponent' is not supported anymore" );
# # simple binary search. The entry is in the range [lo..up]
# lo:=1;
# up:=Length(list);
# while lo<up do
# s := QuoInt(up+lo,2);
# #s:=Int((up+lo)/2);# middle entry
# if list[s][1]<obj then
# lo:=s+1; # it's not in [lo..s], so take the upper part.
# else
# up:=s; # So obj<=list[s][1], so the new range is [1..s].
# fi;
# od;
# # now lo=up
# return lo;
# # if list[lo][1]=obj then
# # return lo;
# # else
# # return fail;
# # fi;
# end );

#############################################################################
##
#M MultVector( <list1>, <poss1>, <list2>, <poss2>, <mult> )
Expand Down
31 changes: 0 additions & 31 deletions src/listfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,36 +552,6 @@ Obj FuncPOSITION_SORTED_LIST_COMP (
}


Obj FuncPOSITION_FIRST_COMPONENT_SORTED (
Obj self,
Obj list,
Obj obj)
{
UInt top, bottom,middle;
Obj x;
Obj l;
bottom = 1;
top = LEN_PLIST(list);
while (bottom <= top) {
middle = (top + bottom)/2;
l = ELM_PLIST(list,middle);
if (!IS_PLIST(l))
return TRY_NEXT_METHOD;
x = ELM_PLIST(l,1);
if (LT(x,obj)) {
bottom = middle+1;
} else if (LT(obj,x)) {
top = middle -1;
} else {
return INTOBJ_INT(middle);
}
}
return INTOBJ_INT(bottom);
}




/****************************************************************************
**
*F SORT_LIST( <list> ) . . . . . . . . . . . . . . . . . . . . sort a list
Expand Down Expand Up @@ -1747,7 +1717,6 @@ static StructGVarFunc GVarFuncs [] = {
GVAR_FUNC(APPEND_LIST_INTR, 2, "list1, list2"),
GVAR_FUNC(POSITION_SORTED_LIST, 2, "list, obj"),
GVAR_FUNC(POSITION_SORTED_LIST_COMP, 3, "list, obj, func"),
GVAR_FUNC(POSITION_FIRST_COMPONENT_SORTED, 2, "list, obj"),
GVAR_FUNC(SORT_LIST, 1, "list"),
GVAR_FUNC(STABLE_SORT_LIST, 1, "list"),
GVAR_FUNC(SORT_LIST_COMP, 2, "list, func"),
Expand Down

0 comments on commit 2f6365a

Please sign in to comment.