#include <xtd/collections/array_list>
#include <xtd/console>
#include <xtd/startup>
class program {
public:
public:
person(const string& first_name, const string last_name) : first_name {first_name}, last_name {last_name} {}
string first_name;
string last_name;
int32 compare_to(
const person& o)
const noexcept override {
if (first_name == o.first_name && last_name == o.last_name) return 0;
if (first_name > o.first_name || (first_name == o.first_name && last_name > o.last_name)) return 1;
return -1;
}
bool equals(const object& o) const noexcept override {return is<person>(o) && equals(as<person>(o));}
bool equals(const person& o) const noexcept override {return compare_to(o) == 0;}
string to_string() const noexcept override {return string::format("{} {}", first_name, last_name);}
};
private:
public:
for (
auto i = 0_z; i < p_array.
size(); ++i)
people_[i] = p_array[i];
}
return enumerator {new_ptr<people_enumerator>(people_)};
}
};
private:
size position = array_list::npos;
public:
people_enumerator(
const array_list& list) : people_(list) {}
bool move_next()
override {
return ++position < people_.
count();}
void reset() override {position = array_list::npos;}
return people_[position];
}
};
static auto main() -> void {
person {"John", "Smith"},
person {"Jim", "Johnson"},
person {"Sue", "Rabon"},
};
auto people_list = people {people_array};
for (auto person : people_list)
console::write_line(person);
}
};
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.h:28
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.h:58
virtual size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(xtd::array::begin(),...
Definition basic_array.h:211
Supports a simple iteration over a generic collection.
Definition enumerator.h:31
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.h:35
Supports a simple iteration over a generic collection.
Definition ienumerator.h:58
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.h:71
size_type count() const noexcept override
Gets the number of elements contained in the xtd::collections::generic::list <type_t>.
Definition list.h:288
virtual size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(xtd::collections::generic::list::...
Definition list.h:364
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.h:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:22
The exception that is thrown when the format of an argument does not meet the parameter specification...
Definition invalid_operation_exception.h:19
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.h:175
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
size_t size
Represents a size of any object in bytes.
Definition size.h:23
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10