Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/tools/jam/src/modules/sequence.c @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.2 KB
Line 
1/* Copyright Vladimir Prus 2003. Distributed under the Boost */
2/* Software License, Version 1.0. (See accompanying */
3/* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */
4
5#include "../native.h"
6
7# ifndef max
8# define max( a,b ) ((a)>(b)?(a):(b))
9# endif
10
11
12LIST *sequence_select_highest_ranked( PARSE *parse, FRAME *frame )
13{
14   /* Returns all of 'elements' for which corresponding element in parallel */
15   /* list 'rank' is equal to the maximum value in 'rank'.                  */
16
17    LIST* elements = lol_get( frame->args, 0 );   
18    LIST* rank = lol_get( frame->args, 1 );   
19   
20    LIST* result = 0;
21    LIST* tmp;
22    int highest_rank = -1;
23
24    for (tmp = rank; tmp; tmp = tmp->next)
25        highest_rank = max(highest_rank, atoi(tmp->string));
26
27    for (; rank; rank = rank->next, elements = elements->next)
28        if (atoi(rank->string) == highest_rank)
29            result = list_new(result, elements->string);
30
31    return result;
32}
33
34void init_sequence()
35{
36    {
37        char* args[] = { "elements", "*", ":", "rank", "*", 0 };
38        declare_native_rule("sequence", "select-highest-ranked", args, 
39                            sequence_select_highest_ranked, 1);
40    }
41
42}
Note: See TracBrowser for help on using the repository browser.