2#ifndef __ASE_EVENTLIST_HH__ 
    3#define __ASE_EVENTLIST_HH__ 
   12template<
class Event, 
class CompareOrder>
 
   17  const Event* lookup           (
const Event &event) 
const;
 
   18  const Event* lookup_after     (
const Event &event) 
const;
 
   20  CompareOrder compare_;
 
 
   24template<
class Event, 
class Compare>
 
   29  using CIter = 
typename EventVector::const_iterator;
 
   31  bool         insert         (
const Event &event, 
Event *replaced = 
nullptr); 
 
   43  CIter        
end            ()
 const { 
return events_.
end(); }   
 
   45  bool         equals         (
const EventVector &ev)
 const { 
return ev == events_; }
 
   53  static void        nop          (
const Event&, 
int) {}
 
   57template<
class Event, 
class Compare> 
inline 
   58EventList<Event,Compare>::EventList (
const Notify &n, 
const Compare &c) :
 
   59  compare_ (c), notify_ (n)
 
   65template<
class Event, 
class Compare> 
inline void 
   72template<
class Event, 
class Compare> 
inline void 
   78template<
class Event, 
class Compare> 
inline bool 
   79EventList<Event,Compare>::insert (
const Event &event, Event *replaced)
 
   82  if (events_.size() && compare_ (event, events_.back()) > 0)
 
   84      events_.push_back (event);
 
   89  auto it = insmatch.first;
 
   90  if (insmatch.second == 
true)  
 
  100      events_.insert (it, event);
 
  106template<
class Event, 
class Compare> 
inline bool 
  110  if (insmatch.second == 
true)  
 
  113      auto it = insmatch.first;
 
 
  123template<
class Event, 
class Compare> 
inline bool 
  127  const int cmp = events_.empty() ? +1 : compare_ (event, events_.
back());
 
  131        *removed = events_.
back();
 
  139      if (it != events_.end())
 
 
  151template<
class Event, 
class Compare> 
inline const Event*
 
  154  return events_.
empty() ? nullptr : &events_.front();
 
 
  157template<
class Event, 
class Compare> 
inline const Event*
 
  160  return events_.
empty() ? nullptr : &events_.back();
 
 
  163template<
class Event, 
class Compare> 
inline size_t 
  166  return events_.size();
 
 
  169template<
class Event, 
class Compare> 
inline const Event*
 
  173  return it != events_.end() ? &*it : 
nullptr;
 
 
  176template<
class Event, 
class Compare> 
inline const Event*
 
  180  return it != events_.end() ? &*it : 
nullptr;
 
 
  183template<
class Event, 
class Compare>
 
 
  198template<
class Event, 
class CompareOrder>
 
  202  auto lesser = [
this] (
const Event &a, 
const Event &b) {
 
  203    return compare_ (a, b) < 0;
 
  208template<
class Event, 
class CompareOrder> 
inline const Event*
 
  209OrderedEventList<Event,CompareOrder>::lookup (
const Event &event)
 const 
  212  return it != this->
end() ? &*it : 
nullptr;
 
  215template<
class Event, 
class CompareOrder> 
inline const Event*
 
  216OrderedEventList<Event,CompareOrder>::lookup_after (
const Event &event)
 const 
  219  return it != this->
end() ? &*it : 
nullptr;
 
 
 
 
 
 
 
 
 
 
Maintain an array of unique Event structures with change notification.
 
bool remove(const Event &event, Event *removed=nullptr)
Only replace event, notifies.
 
CIter end() const
Const iterator that points to the first element.
 
void clear_silently()
Return the numberof elements.
 
OrderedEventList::ConstP ordered_events()
Clear list without notification.
 
bool replace(const Event &event, Event *replaced=nullptr)
Insert or replace event, notifies.
 
CIter begin() const
Create a read-only copy of this EventList (possibly cached).
 
const Event * lookup(const Event &event) const
Return true if event was removed, notifies.
 
size_t size() const
Return last element or nullptr.
 
EventVector copy() const
Const iterator that points one past the last element.
 
const Event * lookup_after(const Event &event) const
Return pointer to matching event or nullptr.
 
const Event * first() const
Return pointer to element that is >= event or nullptr.
 
const Event * last() const
Return first element or nullptr.
 
#define ASE_ASSERT_RETURN(expr,...)
Return from the current function if expr evaluates to false and issue an assertion warning.
 
RandIter binary_lookup(RandIter begin, RandIter end, Cmp cmp_elements, const Arg &arg)
 
std::pair< RandIter, bool > binary_lookup_insertion_pos(RandIter begin, RandIter end, Cmp cmp_elements, const Arg &arg)
 
The Anklang C++ API namespace.
 
Structure for callback based notifications.
 
Container for a sorted array of opaque Event structures with binary lookup.