Scilab: add bool type in STL vector example
This commit is contained in:
parent
bc80012e0a
commit
ca282beae6
4 changed files with 28 additions and 0 deletions
|
|
@ -63,6 +63,18 @@ std::vector<std::string> concat_string_vector(const std::vector<std::string> vec
|
||||||
return concat_vector<std::string>(vector, other_vector);
|
return concat_vector<std::string>(vector, other_vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bool vectors
|
||||||
|
|
||||||
|
std::vector<bool> create_bool_vector(const int size, const bool value)
|
||||||
|
{
|
||||||
|
return std::vector<bool>(size, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<bool> concat_bool_vector(const std::vector<bool> vector, const std::vector<bool> other_vector)
|
||||||
|
{
|
||||||
|
return concat_vector<bool>(vector, other_vector);
|
||||||
|
}
|
||||||
|
|
||||||
// pointer (on objects) vectors
|
// pointer (on objects) vectors
|
||||||
|
|
||||||
std::vector<classA*> create_classA_vector(const int size, const int value)
|
std::vector<classA*> create_classA_vector(const int size, const int value)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,10 @@ std::vector<int> concat_integer_vector(const std::vector<int> vector, const std:
|
||||||
std::vector<std::string> create_string_vector(const int size, const char* value);
|
std::vector<std::string> create_string_vector(const int size, const char* value);
|
||||||
std::vector<std::string> concat_string_vector(const std::vector<std::string> vector, const std::vector<std::string> other_vector);
|
std::vector<std::string> concat_string_vector(const std::vector<std::string> vector, const std::vector<std::string> other_vector);
|
||||||
|
|
||||||
|
// bool vectors
|
||||||
|
std::vector<bool> create_bool_vector(const int size, const bool value);
|
||||||
|
std::vector<bool> concat_bool_vector(const std::vector<bool> vector, const std::vector<bool> other_vector);
|
||||||
|
|
||||||
// pointer (on objects) vectors
|
// pointer (on objects) vectors
|
||||||
class classA
|
class classA
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ namespace std
|
||||||
%template(IntVector) vector<int>;
|
%template(IntVector) vector<int>;
|
||||||
%template(DoubleVector) vector<double>;
|
%template(DoubleVector) vector<double>;
|
||||||
%template(StringVector) vector<std::string>;
|
%template(StringVector) vector<std::string>;
|
||||||
|
%template(BoolVector) vector<bool>;
|
||||||
%template(ClassAVector) vector<classA*>;
|
%template(ClassAVector) vector<classA*>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,17 @@ disp("concat this vector with the vector of string {''bb'', ''bb''} with concat_
|
||||||
sv3 = concat_string_vector(sv, sv2);
|
sv3 = concat_string_vector(sv, sv2);
|
||||||
disp(sv3);
|
disp(sv3);
|
||||||
|
|
||||||
|
// bool vectors
|
||||||
|
|
||||||
|
disp("Example of passing matrices of bool as vector arguments of C++ functions.");
|
||||||
|
disp("get a vector of bool {true, true} with create_bool_vector():");
|
||||||
|
bv = create_bool_vector(2, %T);
|
||||||
|
disp(bv);
|
||||||
|
bv2 = create_bool_vector(3, %F);
|
||||||
|
disp("concat this vector with the vector of bool {false, false, false} with concat_bool_vector():");
|
||||||
|
bv3 = concat_bool_vector(bv, bv2);
|
||||||
|
disp(bv3);
|
||||||
|
|
||||||
// pointer (on object) vectors
|
// pointer (on object) vectors
|
||||||
|
|
||||||
disp("Example of passing list of objects as vector arguments of C++ functions.");
|
disp("Example of passing list of objects as vector arguments of C++ functions.");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue