#include <xtd/xtd>
public:
string part_name;
int part_id = 0;
part() = default;
part(const string& name, int id) : part_name {name}, part_id {id} {}
string to_string()
const noexcept override {
return string::format(
"ID: {} Name: {}", part_id, part_name);}
bool equals(
const part&
other)
const noexcept override {
return part_id ==
other.part_id;}
};
class example {
public:
static auto main() -> void {
parts.add(part {"crank arm", 1234});
parts.add(part {"chain ring", 1334});
parts.add(part {"regular seat", 1434});
parts.add(part {"banana seat", 1444});
parts.add(part {"cassette", 1534});
parts.add(part {"shift lever", 1634});
console::write_line();
for (auto part : parts)
console::write_line(part);
console::write_line("\ncontains(\"1734\"): {0}", parts.contains(part {"", 1734}));
console::write_line("\nInsert(2, \"1834\")");
parts.insert(2, part {"brake lever", 1834});
for (auto part : parts)
console::write_line(part);
console::write_line("\nparts[3]: {0}", parts[3]);
console::write_line("\nremove(\"1534\")");
parts.remove(part {"cogs", 1534});
console::write_line();
for (auto part : parts)
console::write_line(part);
console::write_line("\nremove_at(3)");
parts.remove_at(3);
console::write_line();
for (auto part : parts)
console::write_line(part);
}
};
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:80
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:167
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
bool is(std::any value)
Checks if the result of an expression is compatible with a given type.
Definition is.hpp:365
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.hpp:59
@ other
The operating system is other.
Definition platform_id.hpp:58
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
string to_string() const noexcept override
Returns the string representation of this xtd::read_only_span <type_t> object.
Definition read_only_span.hpp:375
bool equals(const object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
Definition read_only_span.hpp:272
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
Definition read_only_span.hpp:296