Skip to content

ADeque#

A std::deque with AUI extensions.

Header:#include <AUI/Common/ADeque.h>
CMake:aui_link(my_target PUBLIC aui::core)

Public Methods#

contains#


bool ADeque::contains(const StoredType& value)
Returns
true if container contains an element, false otherwise.

Examples:

examples/ui/contacts/src/main.cpp

AUI Contacts — Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.

    _<AView> searchQueryList() {
        auto searchFilter = ranges::views::filter([&](const _<Contact>& c) {
            for (const auto& field : { c->displayName, c->note }) {
                if (field->lowercase().contains(*mSearchQueryLowercased)) {
                    return true;
                }
            }
            return false;
        });

first#


StoredType& ADeque::first()
Returns
the first element.
Sneaky assertions
Container is not empty.

Examples:

examples/7guis/cells/src/AST.cpp

7GUIs Cells — Spreadsheet processor (Excel).

            // should assign it to some operator
            for (const auto& o : binaryOperators | ranges::views::reverse) {
                if (o.op->right == nullptr) {
                    o.op->right = std::move(temporaryValue);
                    AUI_ASSERT(binaryOperators.first().owning != nullptr);
                    return std::move(binaryOperators.first().owning);
                }
            }
            throw AException {};
        }
examples/7guis/cells/src/main.cpp

7GUIs Cells — Spreadsheet processor (Excel).

                      [](const AString& v) -> _<AView> { return Label { "{}"_format(v) }; },
                      [](const formula::Range& v) -> _<AView> { return Label { "#RANGE?" }; },
                    },
                    v));
            connect(getViews().first()->clicked, me::inflateEditor);
        });
    }

    void inflateEditor() {
        mState->currentExpression = mCell.expression;
examples/ui/contacts/src/view/ContactDetailsView.cpp

AUI Contacts — Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.

namespace {
_<AView> profilePhoto(const _<Contact>& contact) {
    return Centered {
        Label {
          AUI_REACT(contact->displayName->empty() ? "?" : AString(1, contact->displayName->first()).uppercase())
        } AUI_OVERRIDE_STYLE { Opacity(0.5f), FontSize { 32_dp } },
    } AUI_OVERRIDE_STYLE {
        FixedSize { 64_dp },
        BorderRadius { 32_dp },
        BackgroundGradient { AColor::GRAY.lighter(0.5f), AColor::GRAY, 163_deg },
examples/ui/views/src/ExampleWindow.cpp

Views Example — All-in-one views building example.

              ATextAlign::CENTER,
            },
        [&]() -> _<AView> {
            if (auto u = event.data.urls()) {
                auto url = u->first();
                if (auto icon = ADesktop::iconOfFile(url.path())) {
                    return Centered { _new<ADrawableView>(icon) AUI_OVERRIDE_STYLE { FixedSize { 64_dp } } };
                }
            }
            return nullptr;

const StoredType& ADeque::first()
Returns
the first element.
Sneaky assertions
Container is not empty.

Examples:

indexOf#


AOptional<size_t> ADeque::indexOf(const StoredType& value)
Arguments
value
element to find.
Returns
index of the specified element. If element is not found, std::nullopt is returned.

insertAll#


template<typename OtherContainer >
iterator ADeque::insertAll(const OtherContainer& c)
Arguments
c
other container
Returns
iterator pointing to the first element inserted.

Inserts all values of the specified container to the end.

Examples:

examples/ui/infinite_lazy_list/src/main.cpp

Infinite Lazy List — Usage of AUI_DECLARATIVE_FOR to make an infinite lazy list.

                return aui::ptr::manage_shared(new Item { .value = "Item {}"_format(loadFrom + i) });
            });

            AUI_UI_THREAD { // back to main thread.
                state->items.writeScope()->insertAll(loadedItems);
                state->needMore = false;
            };
        };
    });

template<typename OtherContainer >
iterator ADeque::insertAll(iterator at, const OtherContainer& c)
Arguments
at
position to insert at.
c
other container
Returns
iterator pointing to the first element inserted.

Inserts all values of the specified container.

Examples:

isSubsetOf#


template<typename OtherContainer >
bool ADeque::isSubsetOf(const OtherContainer& c)
Returns
true if c container is a subset of this container, false otherwise.

last#


StoredType& ADeque::last()
Returns
the last element.
Sneaky assertions
Container is not empty.

Examples:


const StoredType& ADeque::last()
Returns
the last element.
Sneaky assertions
Container is not empty.

Examples:

removeAll#


void ADeque::removeAll(const StoredType& item)
Arguments
item
element to remove.

Removes all occurrences of item.

removeAt#


void ADeque::removeAt(size_t index)
Arguments
index
index of the element.

Removes element at the specified index.

Sneaky assertions
index points to the existing element.

removeFirst#


void ADeque::removeFirst(const StoredType& item)
Arguments
item
element to remove.

Removes first occurrence of item.

Examples:

examples/7guis/crud/src/main.cpp

7GUIs CRUD — Create/Read/Update/Delete example.

        (*mSelectedUser)->surname = std::exchange(mEditedUser.surname, {});
    }

    void deleteClicked() {
        mUsers.writeScope()->removeFirst(*mSelectedUser);
        mSelectedUser = nullptr;
    }
};

AUI_ENTRY {

removeIf#


template<typename Predicate >
void ADeque::removeIf(Predicate&& predicate)
Arguments
predicate
predicate

Removes element if predicate(container[i]) == true.