Skip to content

Commit

Permalink
Added missing insert function for sets.
Browse files Browse the repository at this point in the history
  • Loading branch information
5cript committed Aug 17, 2023
1 parent d4e9f26 commit df7e028
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
32 changes: 30 additions & 2 deletions nui/include/nui/frontend/event_system/observed_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,30 @@ namespace Nui
rangeContext_.reset(0, true);
update();
}
template <typename U = ContainerT>
Detail::PickFirst_t<
std::pair<typename ContainerT::iterator, bool>,
decltype(std::declval<U>().insert(std::declval<const value_type&>()))>
insert(const value_type& value)
{
const auto result = contained_.insert(value);
rangeContext_.performFullRangeUpdate();
update();
globalEventContext.executeActiveEventsImmediately();
return result;
}
template <typename U = ContainerT>
Detail::PickFirst_t<
std::pair<typename ContainerT::iterator, bool>,
decltype(std::declval<U>().insert(std::declval<value_type&&>()))>
insert(value_type&& value)
{
const auto result = contained_.insert(std::move(value));
rangeContext_.performFullRangeUpdate();
update();
globalEventContext.executeActiveEventsImmediately();
return result;
}
iterator insert(iterator pos, const value_type& value)
{
return insert(pos.getWrapped(), value);
Expand Down Expand Up @@ -805,12 +829,16 @@ namespace Nui
insertRangeChecked(distance, distance + std::distance(first, last), RangeStateType::Erase);
return iterator{this, it};
}
void push_back(const value_type& value)
template <typename U = ContainerT>
Detail::PickFirst_t<void, decltype(std::declval<U>().push_back(std::declval<const value_type&>()))>
push_back(const value_type& value)
{
contained_.push_back(value);
insertRangeChecked(size() - 1, size() - 1, RangeStateType::Insert);
}
void push_back(value_type&& value)
template <typename U = ContainerT>
Detail::PickFirst_t<void, decltype(std::declval<U>().push_back(std::declval<value_type>()))>
push_back(value_type&& value)
{
contained_.push_back(std::move(value));
insertRangeChecked(size() - 1, size() - 1, RangeStateType::Insert);
Expand Down
4 changes: 4 additions & 0 deletions nui/include/nui/frontend/event_system/range_event_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ namespace Nui
Accepted, // Accepted, update can be deferred.
Retry // Must update immediately and reissue this.
};
void performFullRangeUpdate()
{
fullRangeUpdate_ = true;
}
InsertResult insertModificationRange(long elementCount, long low, long high, RangeStateType type)
{
if (disableOptimizations_)
Expand Down

0 comments on commit df7e028

Please sign in to comment.