2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-12 12:02:24 +00:00

Improved 'vector'.

* new/container.jam (vector.indices): New rule.
    * new/targets.jam: Use the new rule.


[SVN r14528]
This commit is contained in:
Vladimir Prus
2002-07-19 12:57:23 +00:00
parent 3d408cbe74
commit eeeb3c402c
2 changed files with 15 additions and 1 deletions

View File

@@ -175,7 +175,7 @@ rule main-target ( name : project )
else
{
# Find the alternative with the longest set of non-free requirements
local r = [ range 1 : [ $(alternatives).size ] ] [ $(alternatives).size ] ;
local r = [ $(alternatives).indices ] ;
# First compute the length of requirements sets
local req-length ;

View File

@@ -44,6 +44,8 @@ rule vector (
values * # Initial contents of vector.
)
{
import numbers : range ;
node.__init__ ;
self.value = $(values) ;
@@ -187,6 +189,16 @@ rule vector (
return true ;
}
}
# Returns the list of all valid indices for this vector.
rule indices ( )
{
if ! [ empty ]
{
local size = [ size ] ;
return [ range 1 : $(size) ] $(size) ;
}
}
}
class vector : node ;
@@ -196,8 +208,10 @@ local rule __test__ ( )
local l = [ new vector ] ;
assert.result 0 : $(l).size ;
assert.result : $(l).indices ;
$(l).push-back b ;
$(l).push-front a ;
assert.result 1 2 : $(l).indices ;
assert.result a : $(l).front ;
assert.result b : $(l).back ;
$(l).insert 2 : d ;