QMap<X,Y> m_history;QList<X> m_keys;void InsertItem(X key, Y value){ m_history[key] = value; m_keys.append(key); if (m_keys.size() > MAX_SIZE_ALLOWED) { m_history.remove(m_keys.takeFirst()); }}