AVector#
An std::vector with AUI extensions.
Header: | #include <AUI/Common/AVector.h> |
CMake: | aui_link(my_target PUBLIC aui::core) |
Examples#
examples/app/minesweeper/src/MinesweeperWindow.h
Minesweeper Game - Minesweeper game implementation driven by ass.
int mBombs;
int mOpenedCells;
_<AViewContainer> mGrid;
AVector<FieldCell> mField;
void openCell(int x, int y, bool doGameLoseIfBomb);
int countBombsAround(int x, int y);
bool isValidCell(int x, int y) { return x >= 0 && x < mFieldColumns && y >= 0 && y < mFieldRows; }
FieldCell& fieldAt(int x, int y) { return mField[mFieldColumns * y + x]; }
examples/7guis/cells/src/Functions.h
7GUIs Cells - Spreadsheet processor (Excel).
examples/7guis/cells/src/Spreadsheet.h
7GUIs Cells - Spreadsheet processor (Excel).
examples/7guis/cells/src/Tokens.h
7GUIs Cells - Spreadsheet processor (Excel).
examples/7guis/cells/src/AST.cpp
7GUIs Cells - Spreadsheet processor (Excel).
int priority = -1;
_unique<BinaryOperatorNode> owning;
};
AVector<BinaryOperatorAndItsPriority> binaryOperators;
auto putValue = [&](_unique<INode> node) {
if (temporaryValue) {
throw AException("SYNTAX");
}
examples/7guis/cells/src/Tokens.cpp
7GUIs Cells - Spreadsheet processor (Excel).
examples/7guis/cells/src/main.cpp
7GUIs Cells - Spreadsheet processor (Excel).
Public Methods#
contains#
- Returns
- true if container contains an element, false otherwise.
findIf#
Finds element by predicate
- Arguments
predicate
predicate- Returns
- Pointer to the value on which the predicate returned true, nullptr otherwise
first#
- Returns
- the first element.
- Sneaky assertions
- Container is not empty.
Examples#
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 {} & contact->displayName.readProjected([](const AString& s) {
return s.empty() ? "?" : AString(1, s.first()).uppercase();
}) AUI_WITH_STYLE { Opacity(0.5f), FontSize { 32_dp } },
} AUI_WITH_STYLE {
FixedSize { 64_dp },
BorderRadius { 32_dp },
BackgroundGradient { AColor::GRAY.lighter(0.5f), AColor::GRAY, 163_deg },
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).
- Returns
- the first element.
- Sneaky assertions
- Container is not empty.
Examples#
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 {} & contact->displayName.readProjected([](const AString& s) {
return s.empty() ? "?" : AString(1, s.first()).uppercase();
}) AUI_WITH_STYLE { Opacity(0.5f), FontSize { 32_dp } },
} AUI_WITH_STYLE {
FixedSize { 64_dp },
BorderRadius { 32_dp },
BackgroundGradient { AColor::GRAY.lighter(0.5f), AColor::GRAY, 163_deg },
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).
fromRange#
Constructs a new vector of transformed items of the range.
- Arguments
range
items to transform from.transformer
transformer function.- Returns
- A new vector.
indexOf#
AOptional<size_t> AVector::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#
- Arguments
c
other container- Returns
- iterator pointing to the first element inserted.
Inserts all values of the specified container to the end.
- Arguments
c
other container- Returns
- iterator pointing to the first element inserted.
Inserts all values of the specified container to the end.
template<typename OtherContainer >
iterator AVector::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.
- Arguments
at
position to insert at.c
other container- Returns
- iterator pointing to the first element inserted.
Inserts all values of the specified container.
isSubsetOf#
- Returns
- true if
c
container is a subset of this container, false otherwise.
last#
- Returns
- the last element.
- Sneaky assertions
- Container is not empty.
Examples#
examples/7guis/cells/src/AST.cpp
7GUIs Cells - Spreadsheet processor (Excel).
if (temporaryValue) {
throw AException("SYNTAX");
}
if (!binaryOperators.empty()) {
if (binaryOperators.last().op->right) {
throw AException {};
}
binaryOperators.last().op->right = std::move(node);
return;
}
- Returns
- the last element.
- Sneaky assertions
- Container is not empty.
Examples#
examples/7guis/cells/src/AST.cpp
7GUIs Cells - Spreadsheet processor (Excel).
if (temporaryValue) {
throw AException("SYNTAX");
}
if (!binaryOperators.empty()) {
if (binaryOperators.last().op->right) {
throw AException {};
}
binaryOperators.last().op->right = std::move(node);
return;
}
removeAll#
- Arguments
item
element to remove.
Removes all occurrences of item
.
template<typename T, aui::mapper<const StoredType &, const T &> Projection >
void AVector::removeAll(const T& item, Projection projection)
- Arguments
item
element to remove.projection
callable that transformsconst StoredType&
toconst T&
. Can be any operator() cappable object, including lambda and pointer-to-member.
Removes all occurrences of item
with specified projection.
removeAt#
void AVector::removeAt(size_t index)
- Arguments
Removes element at the specified index.
- Sneaky assertions
index
points to the existing element.
removeFirst#
AOptional<std::size_t> AVector::removeFirst(const StoredType& item)
- Arguments
item
element to remove.- Returns
- If the item is removed, it's index returned.
Removes first occurrence of item
.
removeIf#
- Arguments
predicate
predicate
Removes element if predicate(container[i]) == true
.
removeIfFirst#
- Arguments
predicate
predicate
Removes only the first element if predicate(container[i]) == true
.