Skip to content

Commit

Permalink
for inserting a key/value pair in a std::map insert() is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
LordFilu committed Jun 23, 2023
1 parent 8220345 commit f23e470
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/Dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ namespace dang
uint32_t Dispatcher::registerSubscriber(std::function<void(Event &)> fn, uint16_t filter)
{
_index++;
_subscribers[_index] = _subscriber_wrapper();
_subscriber_wrapper sw{fn, filter, _index};
_subscribers.insert({_index, sw});
/* _subscribers[_index] = _subscriber_wrapper();
_subscribers[_index].fn = fn;
_subscribers[_index].filt = filter;
_subscribers[_index].ind = _index;
return _index;
*/ return _index;

}

Expand Down
3 changes: 2 additions & 1 deletion src/Gear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ namespace dang
void Gear::addImagesheet(std::shared_ptr<Imagesheet> is)
{
assert(!is->getName().empty());
_imagesheets[is->getName()] = is;
_imagesheets.insert({is->getName(), is});
// _imagesheets[is->getName()] = is;
}


Expand Down
9 changes: 8 additions & 1 deletion src/SprIterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ namespace dang
class SpriteObject;
using spSprObj = std::shared_ptr<SpriteObject>;

class SprIterator : public std::iterator<std::forward_iterator_tag, spSprObj>
class SprIterator// : public std::iterator<std::forward_iterator_tag, spSprObj>
{
public:
// https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/
using iterator_category = std::forward_iterator_tag;
using value_type = spSprObj;
using difference_type = spSprObj;
using pointer = spSprObj*;
using reference = spSprObj&;

SprIterator();

// comparison operators. just compare node pointers
Expand Down

0 comments on commit f23e470

Please sign in to comment.