cpp:stl:vector
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
cpp:stl:vector [2020/05/27 16:15] – [Επίδοσης της δομής] gthanos | cpp:stl:vector [2020/05/27 16:30] – [Ένθεση στον πίνακα] gthanos | ||
---|---|---|---|
Line 11: | Line 11: | ||
* Η πράξη της αναζήτησης είναι γραμμική στο μέγεθος των στοιχείων του πίνακα **(Ο(Ν))**. | * Η πράξη της αναζήτησης είναι γραμμική στο μέγεθος των στοιχείων του πίνακα **(Ο(Ν))**. | ||
+ | ==== Ένθεση στον πίνακα ==== | ||
+ | |||
+ | Όπως προαναφέρθηκε, | ||
+ | |||
+ | <code cpp vector_insert.cpp> | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | using namespace std; | ||
+ | |||
+ | template< | ||
+ | void print(vector< | ||
+ | for(auto it = v.cbegin(); it!=v.cend(); | ||
+ | cout << setw(4) << *it; | ||
+ | cout << endl; | ||
+ | } | ||
+ | |||
+ | template< | ||
+ | void print_r(vector< | ||
+ | for(auto it = v.crbegin(); | ||
+ | cout << setw(4) << *it; | ||
+ | cout << endl; | ||
+ | } | ||
+ | |||
+ | int main() { | ||
+ | vector< | ||
+ | for(int i=0; i<10; i++) { | ||
+ | ints.push_back(i+1); | ||
+ | ints.insert(ints.begin(), | ||
+ | } | ||
+ | print(ints); | ||
+ | } | ||
+ | </ | ||
cpp/stl/vector.txt · Last modified: 2023/05/29 19:12 by gthanos