📄 wcvectos.gml
字号:
:SNPF index='prepend' .int prepend( const &lparm. );
.do end
.el .do begin
:SNPF index='prepend' .int prepend( &lparm. );
.do end
:eSNPL.
:SMTICS.
The &fn. inserts the passed element to be the first element in the vector.
.if &lpref. eq Val .do begin
The data stored in the vector is a copy of the data passed as a parameter.
.do end
All vector elements contained in the vector are copied
.if &lpref. eq Val .do begin
(using
.MONO Type's
assignment operator)
.do end
up one index.
:P.
This function is not provided by the
.MONO WC&lpref.SortedVector
class, since all elements must be inserted in sorted order by the
.MONO insert
member function.
:P.
Several different results can occur if the vector is not large enough for
the new element.
If the
.MONO resize_required
.ix resize_required exception
exception is enabled, the exception is thrown.
If the exception is not enabled, the prepend fails if the amount the vector
is to be grown (the second parameter to the constructor) is zero(0).
Otherwise, the vector is automatically grown by
the number of elements specified to the constructor, using the
.MONO resize
member function.
If
.MONO resize
fails, the element is not inserted to the vector and the
.MONO out_of_memory
.ix out_of_memory exception
exception is thrown, if enabled.
:RSLTS.
The &fn. prepends an element to the
.MONO WC&lpref.OrderedVector
object. A TRUE (non-zero) value is returned if the insert is successful.
If the insert fails, a FALSE (zero) value is returned.
:SALSO.
:SAL typ='fun'.append
:SAL typ='fun'.insert
:SAL typ='fun'.insertAt
:SAL typ='omtyp' ocls='WCExcept'.out_of_memory
:SAL typ='omtyp' ocls='WCExcept'.resize_required
:eSALSO.
:eLIBF.
:CMT.======================================================================
:LIBF fmt='mfun' prot='public'.remove
:SNPL.
:SNPFLF .#include <wcvector.h>
:SNPFLF .public:
.if &lpref. eq Val .do begin
:SNPF index='remove' .int remove( const Type & );
.do end
.el .do begin
:SNPF index='remove' .Type * remove( const Type * );
.do end
:eSNPL.
:SMTICS.
The &fn. removes the first element in the vector which is equivalent to
the passed value.
.if &lpref eq Ptr .do begin
Note that comparisons are done on the objects pointed to, not the pointers
themselves.
.do end
All vector elements stored after the removed elements are copied
.if &lpref. eq Val .do begin
(using
.MONO Type's
assignment operator)
.do end
down one index.
:P.
A linear search is used by the
.MONO WC&lpref.OrderedVector
class to find the element being removed. The
.MONO WC&lpref.SortedVector
class uses a binary search.
:RSLTS.
The &fn. removes the first element in the vector which is equivalent
to the passed value.
.if &lpref. eq Val .do begin
A TRUE (non-zero) value is returned if an equivalent element was
contained in the vector and removed.
If the vector did not contain an equivalent value, a FALSE (zero) value
is returned.
.do end
.el .do begin
The removed pointer is returned.
If the vector did not contain an equivalent value, NULL(0) is returned.
.do end
:SALSO.
:SAL typ='fun'.clear
.if &lpref. eq Ptr .do begin
:SAL typ='fun'.clearAndDestroy
.do end
:SAL typ='fun'.find
:SAL typ='fun'.removeAll
:SAL typ='fun'.removeAt
:SAL typ='fun'.removeFirst
:SAL typ='fun'.removeLast
:eSALSO.
:eLIBF.
:CMT.======================================================================
:LIBF fmt='mfun' cllong='yes' prot='public'.removeAll
:SNPL.
:SNPFLF .#include <wcvector.h>
:SNPFLF .public:
:SNPF index='removeAll' .unsigned removeAll( const &lparm. );
:eSNPL.
:SMTICS.
The &fn. removes all elements in the vector which are equivalent to
the passed value.
.if &lpref eq Ptr .do begin
Note that comparisons are done on the objects pointed to, not the pointers
themselves.
.do end
All vector elements stored after the removed elements are copied
.if &lpref. eq Val .do begin
(using
.MONO Type's
assignment operator)
.do end
down one or more indexes to take the place of the removed elements.
:P.
A linear search is used by the
.MONO WC&lpref.OrderedVector
class to find the elements being removed. The
.MONO WC&lpref.SortedVector
class uses a binary search.
:RSLTS.
The &fn. removes all elements in the vector which are equivalent
to the passed value.
The number of elements removed is returned.
:SALSO.
:SAL typ='fun'.clear
.if &lpref. eq Ptr .do begin
:SAL typ='fun'.clearAndDestroy
.do end
:SAL typ='fun'.find
:SAL typ='fun'.occurrencesOf
:SAL typ='fun'.remove
:SAL typ='fun'.removeAt
:SAL typ='fun'.removeFirst
:SAL typ='fun'.removeLast
:eSALSO.
:eLIBF.
:CMT.======================================================================
:LIBF fmt='mfun' cllong='yes' prot='public'.removeAt
:SNPL.
:SNPFLF .#include <wcvector.h>
:SNPFLF .public:
.if &lpref. eq Val .do begin
:SNPF index='removeAt' .int removeAt( int );
.do end
.el .do begin
:SNPF index='removeAt' .Type * removeAt( int );
.do end
:eSNPL.
:SMTICS.
The &fn. removes the element at the given index.
All vector elements stored after the removed elements are copied
.if &lpref. eq Val .do begin
(using
.MONO Type's
assignment operator)
.do end
down one index.
:P.
If the vector is empty and the
.MONO empty_container
.ix empty_container exception
exception is enabled, the exception is thrown.
:P.
If an attempt to remove an element with a negative index is made and the
.MONO index_range
exception is enabled, the exception is thrown.
If the exception is not enabled, the first element is removed from the vector.
Attempting to remove an element with index greater or equal to the number
of entries in the vector also causes the
.MONO index_range
exception to be thrown if enabled. The last element in the vector is removed
if the exception is not enabled.
:RSLTS.
The &fn. removes the element with the given index. If the index is invalid,
the closest element to the given index is removed.
.if &lpref. eq Val .do begin
A TRUE (non-zero) value is returned if an element was removed.
If the vector was empty, FALSE (zero) value is returned.
.do end
.el .do begin
The removed pointer is returned.
If the vector was empty, NULL(0) is returned.
.do end
:SALSO.
:SAL typ='fun'.clear
.if &lpref. eq Ptr .do begin
:SAL typ='fun'.clearAndDestroy
.do end
:SAL typ='fun'.insertAt
:SAL typ='fun'.operator~b[]
:SAL typ='fun'.remove
:SAL typ='fun'.removeAll
:SAL typ='fun'.removeFirst
:SAL typ='fun'.removeLast
:eSALSO.
:eLIBF.
:CMT.======================================================================
:LIBF fmt='mfun' cllong='yes' prot='public'.removeFirst
:SNPL.
:SNPFLF .#include <wcvector.h>
:SNPFLF .public:
.if &lpref. eq Val .do begin
:SNPF index='removeFirst' .int removeFirst();
.do end
.el .do begin
:SNPF index='removeFirst' .Type * removeFirst();
.do end
:eSNPL.
:SMTICS.
The &fn. removes the first element from a vector.
All other vector elements are copied
.if &lpref. eq Val .do begin
(using
.MONO Type's
assignment operator)
.do end
down one index.
:P.
If the vector is empty and the
.MONO empty_container
.ix empty_container exception
exception is enabled, the exception is thrown.
:RSLTS.
The &fn. removes the first element from the vector.
.if &lpref. eq Val .do begin
A TRUE (non-zero) value is returned if an element was removed.
If the vector was empty, FALSE (zero) value is returned.
.do end
.el .do begin
The removed pointer is returned.
If the vector was empty, NULL(0) is returned.
.do end
:SALSO.
:SAL typ='fun'.clear
.if &lpref. eq Ptr .do begin
:SAL typ='fun'.clearAndDestroy
.do end
:SAL typ='fun'.first
:SAL typ='fun'.remove
:SAL typ='fun'.removeAt
:SAL typ='fun'.removeAll
:SAL typ='fun'.removeLast
:eSALSO.
:eLIBF.
:CMT.======================================================================
:LIBF fmt='mfun' cllong='yes' prot='public'.removeLast
:SNPL.
:SNPFLF .#include <wcvector.h>
:SNPFLF .public:
.if &lpref. eq Val .do begin
:SNPF index='removeLast' .int removeLast();
.do end
.el .do begin
:SNPF index='removeLast' .Type * removeLast();
.do end
:eSNPL.
:SMTICS.
The &fn. removes the last element from a vector.
If the vector is empty and the
.MONO empty_container
.ix empty_container exception
exception is enabled, the exception is thrown.
:RSLTS.
The &fn. removes the last element from the vector.
.if &lpref. eq Val .do begin
A TRUE (non-zero) value is returned if an element was removed.
If the vector was empty, FALSE (zero) value is returned.
.do end
.el .do begin
The removed pointer is returned.
If the vector was empty, NULL(0) is returned.
.do end
:SALSO.
:SAL typ='fun'.clear
.if &lpref. eq Ptr .do begin
:SAL typ='fun'.clearAndDestroy
.do end
:SAL typ='fun'.last
:SAL typ='fun'.remove
:SAL typ='fun'.removeAt
:SAL typ='fun'.removeAll
:SAL typ='fun'.removeFirst
:eSALSO.
:eLIBF.
:CMT.======================================================================
:LIBF fmt='mfun' prot='public'.resize
:SNPL.
:SNPFLF .#include <wcvector.h>
:SNPFLF .public:
:SNPF index='resize' .int resize( size_t new_size );
:eSNPL.
:SMTICS.
The &fn. is used to change the vector size to be able to store
:HP1.new_size:eHP1. elements.
If :HP1.new_size:eHP1. is larger than the previous vector size, all
elements are copied
.if &lpref eq Val .do begin
(using
.MONO Type's
copy constructor)
.do end
into the newly sized vector, and new elements can be added using the
.MONO append, insert, insertAt,
and
.MONO prepend
member functions.
If the vector is resized to a smaller size, the first :HP1.new_size:eHP1.
elements are copied (all vector elements if the vector contained
:HP1.new_size:eHP1. or fewer elements).
.if &lpref eq Val .do begin
The remaining elements are destroyed using
.MONO Type's
destructor.
.do end
.el .do begin
The objects pointed to by the remaining elements are not deleted.
.do end
:P.
If the resize cannot be performed and the
.MONO out_of_memory
.ix out_of_memory exception
exception is enabled, the exception is thrown.
:RSLTS.
The vector is resized to :HP1.new_size:eHP1.:PERIOD.
A TRUE value (non-zero) is returned if the resize is successful.
A FALSE (zero) result is returned if the resize fails.
:SALSO.
:SAL typ='omtyp' ocls='WCExcept'.out_of_memory
:eSALSO.
:eLIBF.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -