- if ( ( group < (*i)->GetGroup() )
- ||( group == (*i)->GetGroup() && elem < (*i)->GetElement()) )
- {
- // instead of ReplaceOrCreate
- // that is a method of Document :-(
- ValEntry* entry = 0;
- TagKey key = DictEntry::TranslateToKey(group, elem);
-
- // we assume a Public Dictionary *is* loaded
- Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
- // if the invoked (group,elem) doesn't exist inside the Dictionary
- // we create a VirtualDictEntry
- DictEntry *dictEntry = pubDict->GetEntry(group, elem);
- if (dictEntry == NULL)
- {
- dictEntry =
- Global::GetDicts()->NewVirtualDictEntry(group, elem,
- "UN", GDCM_UNKNOWN,
- GDCM_UNKNOWN);
- }
- // we assume the constructor didn't fail
- entry = new ValEntry(dictEntry);
- if (entry)
- {
- entry->SetValue(val);
- }
- DocEntries.insert(i,entry);
+/**
+ * \brief Inserts *in the right place* any Entry (Dicom Element)
+ * into the Sequence Item
+ * @param entry Entry to add
+ * @return always true
+ */
+bool SQItem::AddEntry(DocEntry *entry)
+{
+ if (DocEntries.empty() )
+ {
+ DocEntries.push_back(entry);
+ entry->Register();
+ return true;
+ }
+
+ ListDocEntry::iterator insertSpot;
+ ListDocEntry::iterator it = DocEntries.end();
+ do
+ {
+ it--;