improved Array: use std::vector

This commit is contained in:
2023-12-03 13:41:29 +03:00
parent 6b7bde1471
commit c4b8e2dd7a
8 changed files with 42 additions and 45 deletions

View File

@@ -5,18 +5,20 @@
class Text : public Array<String> {
public:
void Print() {
printf("text length=%ld\n", length);
void Print() const {
printf("text length=%ld\n", this->getLength());
for (long i = 0; i < length; ++i) {
printf("i=%ld; [%s]\n", i, elements[i]->getCharArray());
auto elems = this->getElements();
for (size_t i = 0; i < elems.size(); ++i) {
printf("i=%ld; [%s]\n", i, elems[i]->getCharArray());
// elements[i]->println();
}
}
bool hasMatch(const String& s) {
for (long i = 0; i < length; ++i) {
if (s.contains(*elements[i])) {
bool hasMatch(const String& s) const {
for (auto& elem : this->getElements()) {
if (s.contains(*elem)) {
//printf("match: [%s]\n", elements[i]->getCharArray());
return true;
}