1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0023465: Weird InsertBefore, InsertAfter and Remove methods in TDataStd lists

This commit is contained in:
vro
2015-12-09 10:18:28 +03:00
committed by bugmaster
parent c785481848
commit 1ff072271f
12 changed files with 1043 additions and 0 deletions

View File

@@ -133,6 +133,74 @@ const TDataStd_ListOfByte& TDataStd_BooleanList::List() const
return myList;
}
//=======================================================================
//function : InsertBefore
//purpose : Inserts the <value> before the <index> position.
//=======================================================================
Standard_Boolean TDataStd_BooleanList::InsertBefore(const Standard_Integer index,
const Standard_Boolean before_value)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TDataStd_ListIteratorOfListOfByte itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.InsertBefore(before_value ? 1 : 0, itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : InsertAfter
//purpose : Inserts the <value> after the <index> position.
//=======================================================================
Standard_Boolean TDataStd_BooleanList::InsertAfter(const Standard_Integer index,
const Standard_Boolean after_value)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TDataStd_ListIteratorOfListOfByte itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.InsertAfter(after_value ? 1 : 0, itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : Remove
//purpose : Removes the <value> at the <index> position.
//=======================================================================
Standard_Boolean TDataStd_BooleanList::Remove(const Standard_Integer index)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TDataStd_ListIteratorOfListOfByte itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.Remove(itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : ID
//purpose :

View File

@@ -68,6 +68,17 @@ public:
//! 0 - means FALSE.
Standard_EXPORT const TDataStd_ListOfByte& List() const;
//! Inserts the <value> before the <index> position.
//! The indices start with 1 .. Extent().
Standard_EXPORT Standard_Boolean InsertBefore (const Standard_Integer index, const Standard_Boolean before_value);
//! Inserts the <value> after the <index> position.
//! The indices start with 1 .. Extent().
Standard_EXPORT Standard_Boolean InsertAfter (const Standard_Integer index, const Standard_Boolean after_value);
//! Removes a value at <index> position.
Standard_EXPORT Standard_Boolean Remove (const Standard_Integer index);
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE;

View File

@@ -117,6 +117,29 @@ Standard_Boolean TDataStd_ExtStringList::InsertBefore(const TCollection_Extended
return Standard_False;
}
//=======================================================================
//function : InsertBefore
//purpose : Inserts the <value> before the <index> position.
//=======================================================================
Standard_Boolean TDataStd_ExtStringList::InsertBefore(const Standard_Integer index,
const TCollection_ExtendedString& before_value)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TDataStd_ListIteratorOfListOfExtendedString itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.InsertBefore(before_value, itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : InsertAfter
//purpose :
@@ -137,6 +160,29 @@ Standard_Boolean TDataStd_ExtStringList::InsertAfter(const TCollection_ExtendedS
return Standard_False;
}
//=======================================================================
//function : InsertAfter
//purpose : Inserts the <value> after the <index> position.
//=======================================================================
Standard_Boolean TDataStd_ExtStringList::InsertAfter(const Standard_Integer index,
const TCollection_ExtendedString& after_value)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TDataStd_ListIteratorOfListOfExtendedString itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.InsertAfter(after_value, itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : Remove
//purpose :
@@ -156,6 +202,28 @@ Standard_Boolean TDataStd_ExtStringList::Remove(const TCollection_ExtendedString
return Standard_False;
}
//=======================================================================
//function : Remove
//purpose : Removes a value at <index> position.
//=======================================================================
Standard_Boolean TDataStd_ExtStringList::Remove(const Standard_Integer index)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TDataStd_ListIteratorOfListOfExtendedString itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (index == i)
{
Backup();
myList.Remove(itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : Clear
//purpose :

View File

@@ -62,12 +62,23 @@ public:
//! Inserts the <value> before the first meet of <before_value>.
Standard_EXPORT Standard_Boolean InsertBefore (const TCollection_ExtendedString& value, const TCollection_ExtendedString& before_value);
//! Inserts the <value> before the <index> position.
//! The indices start with 1 .. Extent().
Standard_EXPORT Standard_Boolean InsertBefore (const Standard_Integer index, const TCollection_ExtendedString& before_value);
//! Inserts the <value> after the first meet of <after_value>.
Standard_EXPORT Standard_Boolean InsertAfter (const TCollection_ExtendedString& value, const TCollection_ExtendedString& after_value);
//! Inserts the <value> after the <index> position.
//! The indices start with 1 .. Extent().
Standard_EXPORT Standard_Boolean InsertAfter (const Standard_Integer index, const TCollection_ExtendedString& after_value);
//! Removes the first meet of the <value>.
Standard_EXPORT Standard_Boolean Remove (const TCollection_ExtendedString& value);
//! Removes a value at <index> position.
Standard_EXPORT Standard_Boolean Remove (const Standard_Integer index);
Standard_EXPORT void Clear();
Standard_EXPORT const TCollection_ExtendedString& First() const;

View File

@@ -116,6 +116,27 @@ Standard_Boolean TDataStd_IntegerList::InsertBefore(const Standard_Integer value
return Standard_False;
}
// Inserts the <value> before the <index> position.
// The indices start with 1 .. Extent().
Standard_Boolean TDataStd_IntegerList::InsertBeforeByIndex (const Standard_Integer index,
const Standard_Integer before_value)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TColStd_ListIteratorOfListOfInteger itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.InsertBefore(before_value, itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : InsertAfter
//purpose :
@@ -135,6 +156,27 @@ Standard_Boolean TDataStd_IntegerList::InsertAfter(const Standard_Integer value,
}
return Standard_False;
}
// Inserts the <value> after the <index> position.
// The indices start with 1 .. Extent().
Standard_Boolean TDataStd_IntegerList::InsertAfterByIndex (const Standard_Integer index,
const Standard_Integer after_value)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TColStd_ListIteratorOfListOfInteger itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.InsertAfter(after_value, itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : Remove
@@ -155,6 +197,28 @@ Standard_Boolean TDataStd_IntegerList::Remove(const Standard_Integer value)
return Standard_False;
}
//=======================================================================
//function : Remove
//purpose : Removes the <value> at the <index> position.
//=======================================================================
Standard_Boolean TDataStd_IntegerList::RemoveByIndex (const Standard_Integer index)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TColStd_ListIteratorOfListOfInteger itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.Remove(itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : Clear
//purpose :

View File

@@ -61,12 +61,23 @@ public:
//! Inserts the <value> before the first meet of <before_value>.
Standard_EXPORT Standard_Boolean InsertBefore (const Standard_Integer value, const Standard_Integer before_value);
//! Inserts the <value> before the <index> position.
//! The indices start with 1 .. Extent().
Standard_EXPORT Standard_Boolean InsertBeforeByIndex (const Standard_Integer index, const Standard_Integer before_value);
//! Inserts the <value> after the first meet of <after_value>.
Standard_EXPORT Standard_Boolean InsertAfter (const Standard_Integer value, const Standard_Integer after_value);
//! Inserts the <value> after the <index> position.
//! The indices start with 1 .. Extent().
Standard_EXPORT Standard_Boolean InsertAfterByIndex (const Standard_Integer index, const Standard_Integer after_value);
//! Removes the first meet of the <value>.
Standard_EXPORT Standard_Boolean Remove (const Standard_Integer value);
//! Removes a value at <index> position.
Standard_EXPORT Standard_Boolean RemoveByIndex (const Standard_Integer index);
Standard_EXPORT void Clear();
Standard_EXPORT Standard_Integer First() const;

View File

@@ -116,6 +116,27 @@ Standard_Boolean TDataStd_RealList::InsertBefore(const Standard_Real value,
return Standard_False;
}
// Inserts the <value> before the <index> position.
// The indices start with 1 .. Extent().
Standard_Boolean TDataStd_RealList::InsertBeforeByIndex (const Standard_Integer index,
const Standard_Real before_value)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TColStd_ListIteratorOfListOfReal itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.InsertBefore(before_value, itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : InsertAfter
//purpose :
@@ -136,6 +157,27 @@ Standard_Boolean TDataStd_RealList::InsertAfter(const Standard_Real value,
return Standard_False;
}
// Inserts the <value> after the <index> position.
// The indices start with 1 .. Extent().
Standard_Boolean TDataStd_RealList::InsertAfterByIndex (const Standard_Integer index,
const Standard_Real after_value)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TColStd_ListIteratorOfListOfReal itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.InsertAfter(after_value, itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : Remove
//purpose :
@@ -155,6 +197,28 @@ Standard_Boolean TDataStd_RealList::Remove(const Standard_Real value)
return Standard_False;
}
//=======================================================================
//function : Remove
//purpose : Removes a value at the <index> position.
//=======================================================================
Standard_Boolean TDataStd_RealList::RemoveByIndex (const Standard_Integer index)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TColStd_ListIteratorOfListOfReal itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.Remove(itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : Clear
//purpose :

View File

@@ -62,12 +62,23 @@ public:
//! Inserts the <value> before the first meet of <before_value>.
Standard_EXPORT Standard_Boolean InsertBefore (const Standard_Real value, const Standard_Real before_value);
//! Inserts the <value> before the <index> position.
//! The indices start with 1 .. Extent().
Standard_EXPORT Standard_Boolean InsertBeforeByIndex (const Standard_Integer index, const Standard_Real before_value);
//! Inserts the <value> after the first meet of <after_value>.
Standard_EXPORT Standard_Boolean InsertAfter (const Standard_Real value, const Standard_Real after_value);
//! Inserts the <value> after the <index> position.
//! The indices start with 1 .. Extent().
Standard_EXPORT Standard_Boolean InsertAfterByIndex (const Standard_Integer index, const Standard_Real after_value);
//! Removes the first meet of the <value>.
Standard_EXPORT Standard_Boolean Remove (const Standard_Real value);
//! Removes a value at <index> position.
Standard_EXPORT Standard_Boolean RemoveByIndex (const Standard_Integer index);
Standard_EXPORT void Clear();
Standard_EXPORT Standard_Real First() const;

View File

@@ -117,6 +117,27 @@ Standard_Boolean TDataStd_ReferenceList::InsertBefore(const TDF_Label& value,
return Standard_False;
}
// Inserts the label before the <index> position.
// The indices start with 1 .. Extent().
Standard_Boolean TDataStd_ReferenceList::InsertBefore (const Standard_Integer index,
const TDF_Label& before_value)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TDF_ListIteratorOfLabelList itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.InsertBefore(before_value, itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : InsertAfter
//purpose :
@@ -137,6 +158,27 @@ Standard_Boolean TDataStd_ReferenceList::InsertAfter(const TDF_Label& value,
return Standard_False;
}
// Inserts the label after the <index> position.
// The indices start with 1 .. Extent().
Standard_Boolean TDataStd_ReferenceList::InsertAfter (const Standard_Integer index,
const TDF_Label& after_value)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TDF_ListIteratorOfLabelList itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.InsertAfter(after_value, itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : Remove
//purpose :
@@ -156,6 +198,28 @@ Standard_Boolean TDataStd_ReferenceList::Remove(const TDF_Label& value)
return Standard_False;
}
//=======================================================================
//function : Remove
//purpose : Removes a label at the <index> position.
//=======================================================================
Standard_Boolean TDataStd_ReferenceList::Remove (const Standard_Integer index)
{
Standard_Integer i(1);
Standard_Boolean found(Standard_False);
TDF_ListIteratorOfLabelList itr(myList);
for (; itr.More(); itr.Next(), ++i)
{
if (i == index)
{
Backup();
myList.Remove(itr);
found = Standard_True;
break;
}
}
return found;
}
//=======================================================================
//function : Clear
//purpose :

View File

@@ -62,12 +62,23 @@ public:
//! Inserts the <value> before the first meet of <before_value>.
Standard_EXPORT Standard_Boolean InsertBefore (const TDF_Label& value, const TDF_Label& before_value);
//! Inserts the label before the <index> position.
//! The indices start with 1 .. Extent().
Standard_EXPORT Standard_Boolean InsertBefore (const Standard_Integer index, const TDF_Label& before_value);
//! Inserts the <value> after the first meet of <after_value>.
Standard_EXPORT Standard_Boolean InsertAfter (const TDF_Label& value, const TDF_Label& after_value);
//! Inserts the label after the <index> position.
//! The indices start with 1 .. Extent().
Standard_EXPORT Standard_Boolean InsertAfter (const Standard_Integer index, const TDF_Label& after_value);
//! Removes the first meet of the <value>.
Standard_EXPORT Standard_Boolean Remove (const TDF_Label& value);
//! Removes a label at "index" position.
Standard_EXPORT Standard_Boolean Remove (const Standard_Integer index);
Standard_EXPORT void Clear();
Standard_EXPORT const TDF_Label& First() const;