improved Array: use std::vector
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user