C++ (Qt)void Container::SetSelectFlag( Element * elem, bool on ){ if (elem->mSelected != on) { m_SelectedCount += on ? 1 : -1; elem->m_Selected = on; }}
C++ (Qt)void Container::DeleteElement( Element * elem ){ m_SelectedCount -= elem->m_Selected ? 1 : 0; Q_ASSERT(m_SelectedCount >= 0); // и удаляем эл-т }
C++ (Qt)struct Container {... QVector<Element *> mElements;};