+RowItemOwner* View::find_prevalent_trace_group(
+ const shared_ptr<sigrok::ChannelGroup> &group,
+ const unordered_map<shared_ptr<sigrok::Channel>, shared_ptr<Signal> >
+ &signal_map)
+{
+ assert(group);
+
+ unordered_set<RowItemOwner*> owners;
+ vector<RowItemOwner*> owner_list;
+
+ // Make a set and a list of all the owners
+ for (const auto &channel : group->channels()) {
+ const auto iter = signal_map.find(channel);
+ if (iter == signal_map.end())
+ continue;
+
+ RowItemOwner *const o = (*iter).second->owner();
+ owner_list.push_back(o);
+ owners.insert(o);
+ }
+
+ // Iterate through the list of owners, and find the most prevalent
+ size_t max_prevalence = 0;
+ RowItemOwner *prevalent_owner = nullptr;
+ for (RowItemOwner *owner : owners) {
+ const size_t prevalence = std::count_if(
+ owner_list.begin(), owner_list.end(),
+ [&](RowItemOwner *o) { return o == owner; });
+ if (prevalence > max_prevalence) {
+ max_prevalence = prevalence;
+ prevalent_owner = owner;
+ }
+ }
+
+ return prevalent_owner;
+}
+
+vector< shared_ptr<Trace> > View::extract_new_traces_for_channels(