]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/util/sequence.py
1 # (C) Copyright David Abrahams 2002. Permission to copy, use, modify, sell and
2 # distribute this software is granted provided this copyright notice appears in
3 # all copies. This software is provided "as is" without express or implied
4 # warranty, and with no claim as to its suitability for any purpose.
8 from b2
.util
import is_iterable
11 def unique (values
, stable
=False):
12 assert is_iterable(values
)
22 return list(set(values
))
24 def max_element (elements
, ordered
= None):
25 """ Returns the maximum number in 'elements'. Uses 'ordered' for comparisons,
26 or '<' is none is provided.
28 assert is_iterable(elements
)
29 assert callable(ordered
) or ordered
is None
30 if not ordered
: ordered
= operator
.lt
33 for e
in elements
[1:]:
39 def select_highest_ranked (elements
, ranks
):
40 """ Returns all of 'elements' for which corresponding element in parallel
41 list 'rank' is equal to the maximum value in 'rank'.
43 assert is_iterable(elements
)
44 assert is_iterable(ranks
)
48 max_rank
= max_element (ranks
)
52 if ranks
[0] == max_rank
:
53 result
.append (elements
[0])
55 elements
= elements
[1:]