| | | Selection of and access to parts |
Selection of and access to parts
The following program lines
use these routines:
...
m_il_v(8L,a);
m_i_i(5L,s_v_i(a,3L));
println(s_v_i(a,2L));
println(s_v_l(a));
printf("%ld\n",s_v_li(a)+3);
...
The routine s_v_i(), selects the ith object of the vector, the routine
s_v_l() selects the length of a VECTORobject, and as you know that this
is
an INTEGERobject you can access the INTvalue of the length with s_v_li().
So the output of the above program, will be the following three lines
#
8
11
There are also routines, which allow you to access the pointer to the array
of objects, this is the routine s_v_s(), and if you know that the entries
of the VECTORobject are INTEGERobjects you can access their INTvalues using
s_v_ii(). Here is the complete description:
- NAME: s_v_l means
select_vectorobject_length,
while s_v_li abbreviates
select_vectorobject_lengthinteger
- SYNOPSIS:
OP s_v_l(OP vectorobject)
INT s_v_li(OP vectorobject)
- DESCRIPTION: selects the length of an VECTORobject. There is first a
check whether it is really an VECTORobject. There is also a
check whether the length is a not negative number.
- RETURN: s_v_l gives the length part of the VECTORobject, this is
an INTEGERobject, it is not a copy of the length part.
s_v_li gives the INTvalue of the length part. It is equivalent
to s_i_i(s_v_l()). If an error occured s_v_l returns NULL
and s_v_li() returns ERROR.
- MACRO: there are macro versions which do no checks, they are called
S_V_L and S_V_LI
To access the parts of the VECTORobject, there is the routine s_v_i(),
which selects the ith element,
and the routine s_v_ii(), which gives you the INTvalue, of the
i-th object of the VECTORobject, which must be an INTEGERobject.
- NAME: s_v_i means
select_vectorobject_ithobject_as_INT
while
s_v_ii abbreviates
select_vectorobject_ithobjectinteger
- SYNOPSIS:
OP s_v_i(OP vectorobject; INT index)
INT s_v_ii(OP vectorobject; INT index)
- DESCRIPTION: selects the ith entry of an VECTORobject. There is first a
check whether it is really an VECTORobject. Then there is a check
whether index is a value inside the length, and in the case of
s_v_ii there is also a check whether it is an INTEGERobject.
As the VECTORobject is indexed by INT-numbers there is a
(theoretical) limit on the size of a VECTORobject, namely
there are maximal 231 objects inside a VECTORobject.
- RETURN: s_v_i gives the ith entry of the VECTORobject. In the case
of an error it returns NULL. s_v_ii is equivalent to s_i_i(s_v_i()).
It return the INTvalue or ERROR
- MACRO: there are macro versions which do no checks, they are called
S_V_I and S_V_II
harald.fripertinger@kfunigraz.ac.at,
last changed: November 19, 2001
| | | Selection of and access to parts |