mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-07 06:02:20 -04:00
Generalize RecentEntries find() method name.
This commit is contained in:
parent
fc7a7d753d
commit
5a864d8d44
2 changed files with 6 additions and 6 deletions
|
@ -218,7 +218,7 @@ void AISRecentEntry::update(const ais::Packet& packet) {
|
||||||
|
|
||||||
const AISRecentEntry& AISRecentEntries::on_packet(const ais::Packet& packet) {
|
const AISRecentEntry& AISRecentEntries::on_packet(const ais::Packet& packet) {
|
||||||
const auto source_id = packet.source_id();
|
const auto source_id = packet.source_id();
|
||||||
auto matching_recent = find_by_mmsi(source_id);
|
auto matching_recent = find(source_id);
|
||||||
if( matching_recent != std::end(entries) ) {
|
if( matching_recent != std::end(entries) ) {
|
||||||
// Found within. Move to front of list, increment counter.
|
// Found within. Move to front of list, increment counter.
|
||||||
entries.push_front(*matching_recent);
|
entries.push_front(*matching_recent);
|
||||||
|
@ -234,7 +234,7 @@ const AISRecentEntry& AISRecentEntries::on_packet(const ais::Packet& packet) {
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
AISRecentEntries::ContainerType::const_iterator AISRecentEntries::find_by_mmsi(const ais::MMSI key) const {
|
AISRecentEntries::ContainerType::const_iterator AISRecentEntries::find(const ais::MMSI key) const {
|
||||||
return std::find_if(
|
return std::find_if(
|
||||||
std::begin(entries), std::end(entries),
|
std::begin(entries), std::end(entries),
|
||||||
[key](const AISRecentEntry& e) { return e.mmsi == key; }
|
[key](const AISRecentEntry& e) { return e.mmsi == key; }
|
||||||
|
@ -286,7 +286,7 @@ bool AISRecentEntriesView::on_encoder(const EncoderEvent event) {
|
||||||
bool AISRecentEntriesView::on_key(const ui::KeyEvent event) {
|
bool AISRecentEntriesView::on_key(const ui::KeyEvent event) {
|
||||||
if( event == ui::KeyEvent::Select ) {
|
if( event == ui::KeyEvent::Select ) {
|
||||||
if( on_select ) {
|
if( on_select ) {
|
||||||
const auto selected = recent.find_by_mmsi(selected_key);
|
const auto selected = recent.find(selected_key);
|
||||||
if( selected != std::end(recent) ) {
|
if( selected != std::end(recent) ) {
|
||||||
on_select(*selected);
|
on_select(*selected);
|
||||||
return true;
|
return true;
|
||||||
|
@ -323,7 +323,7 @@ void AISRecentEntriesView::paint(Painter& painter) {
|
||||||
Rect target_rect { r.pos, { r.width(), s.font.line_height() }};
|
Rect target_rect { r.pos, { r.width(), s.font.line_height() }};
|
||||||
const size_t visible_item_count = r.height() / s.font.line_height();
|
const size_t visible_item_count = r.height() / s.font.line_height();
|
||||||
|
|
||||||
auto selected = recent.find_by_mmsi(selected_key);
|
auto selected = recent.find(selected_key);
|
||||||
if( selected == std::end(recent) ) {
|
if( selected == std::end(recent) ) {
|
||||||
selected = std::begin(recent);
|
selected = std::begin(recent);
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ void AISRecentEntriesView::paint(Painter& painter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AISRecentEntriesView::advance(const int32_t amount) {
|
void AISRecentEntriesView::advance(const int32_t amount) {
|
||||||
auto selected = recent.find_by_mmsi(selected_key);
|
auto selected = recent.find(selected_key);
|
||||||
if( selected == std::end(recent) ) {
|
if( selected == std::end(recent) ) {
|
||||||
if( recent.empty() ) {
|
if( recent.empty() ) {
|
||||||
selected_key = invalid_key;
|
selected_key = invalid_key;
|
||||||
|
|
|
@ -85,7 +85,7 @@ public:
|
||||||
return entries.front();
|
return entries.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainerType::const_iterator find_by_mmsi(const ais::MMSI key) const;
|
ContainerType::const_iterator find(const ais::MMSI key) const;
|
||||||
|
|
||||||
ContainerType::const_iterator begin() const {
|
ContainerType::const_iterator begin() const {
|
||||||
return entries.begin();
|
return entries.begin();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue