#include <xtd/collections/array_list>
#include <xtd/array>
#include <xtd/console>
#include <xtd/not_implemented_exception>
#include <xtd/startup>
class program {
public:
static auto main() -> void {
auto test = simple_list();
test.add("one");
test.add("two");
test.add("three");
test.add("four");
test.add("five");
test.add("six");
test.add("seven");
test.add("eight");
test.print_contents();
test.remove("six");
test.remove("eight");
test.print_contents();
test.add("nine");
test.print_contents();
test.insert(4, "number");
test.print_contents();
}
private:
public:
inline static constexpr size npos = ilist::npos;
simple_list() {count_ = 0;}
void print_contents() const noexcept {
for (
auto i = 0_z;
i < count(); ++
i)
}
bool is_fixed_size() const noexcept override {return true;}
bool is_read_only() const noexcept override {return false;}
if (count_ < contents_.
size()) {
contents_[count_] = value;
count_++;
}
}
count_ = 0;
}
bool contains(
const any_object& value)
const noexcept override {
for (
auto i = 0_z;
i < count(); ++
i)
if (contents_[
i] == value)
return true;
return false;
}
for (
auto i = 0_z;
i < count(); ++
i)
if (contents_[
i] == value)
return i;
return npos;
}
if (count_ + 1 <= contents_.
size() && index < count()) {
++count_;
for (
size i = count() - 1;
i > index; --
i)
contents_[
i] = contents_[
i - 1];
contents_[index] = value;
}
}
auto index = index_of(value);
remove_at(index);
return index != npos;
}
void remove_at(
size index)
override {
if (index < count()) {
for (
size i = index;
i < count() - 1; ++
i)
contents_[
i] = contents_[
i + 1];
--count_;
}
}
return contents_[index];
}
return contents_[index];
}
size count()
const noexcept override {
return count_;}
bool is_synchronized() const noexcept override {return false;}
const object& sync_root() const noexcept override {return *this;}
for (
auto i = 0_z;
i < count(); ++
i)
}
}
};
};
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:29
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
virtual size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(xtd::array::begin(),...
Definition basic_array.hpp:229
static void write(arg_t &&value)
Writes the text representation of the specified value to the standard output stream.
Definition console.hpp:462
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
The exception that is thrown when a requested method or operation is not implemented.
Definition not_implemented_exception.hpp:19
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
generic::enumerator< xtd::any_object > enumerator
Supports a simple iteration over a non-generic collection.
Definition enumerator.hpp:28
generic::ilist< xtd::any_object > ilist
Represents a non-generic collection of objects that can be individually accessed by index.
Definition ilist.hpp:32
#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
@ clear
The CLEAR key.
Definition console_key.hpp:26
@ add
The Add key.
Definition console_key.hpp:170
@ i
The I key.
Definition console_key.hpp:104
@ insert
The INS (INSERT) key.
Definition console_key.hpp:62
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
void copy_to(span< type_t, length > &destination) const
Copies the contents of this xtd::read_only_span <type_t> into a destination xtd:span <type_t>.
Definition read_only_span.hpp:264