From 00a8cf0646cba78bcfb86987f62e38b6e43d22eb Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Tue, 2 Jul 2002 20:39:20 +0000 Subject: [PATCH] Added list.get-at that returns the value of an item, assumes that the item is a node. Added support for n-recursive access to list.at and list.get-at to make access to recursive structures easier. [SVN r14285] --- src/util/container.jam | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/util/container.jam b/src/util/container.jam index d36c1fceb..dad5d271f 100644 --- a/src/util/container.jam +++ b/src/util/container.jam @@ -50,9 +50,24 @@ rule list ( return $(self.value[-1]) ; } - rule at ( index ) + rule at ( index : * ) { - return $(self.value[$(index)]) ; + local r = $(self.value[$(index)]) ; + if $(2) + { + r = [ $(r).at $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ] ; + } + return $(r) ; + } + + rule get-at ( index : * ) + { + local r = $(self.value[$(index)]) ; + if $(2) + { + r = [ $(r).at $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ] ; + } + return [ $(r).get ] ; } rule push-front ( value ) @@ -147,4 +162,13 @@ local rule __test__ ( ) assert.false $(l2-alias).empty ; $(l2).pop-back ; assert.result t : $(l2-alias).back ; + + local l3 = [ new list ] ; + $(l3).push-back [ new list 1 2 3 4 5 ] ; + $(l3).push-back [ new list a b c ] ; + $(l3).push-back [ new list [ new list x y z ] [ new list 7 8 9 ] ] ; + assert.result 1 : $(l3).at 1 : 1 ; + assert.result b : $(l3).at 2 : 2 ; + assert.result a b c : $(l3).get-at 2 ; + assert.result 7 8 9 : $(l3).get-at 3 : 2 ; }