[Visual Basic .NET] |
---|
Public Property Recycling() As Boolean
|
[C#] |
---|
public bool Recycling {get; set;}
|
[Managed C++] |
---|
public: __property bool get_Recycling();
|
[Unmanaged C++] |
---|
public: HRESULT get_Recycling(
|
[Java] |
---|
public bool getRecycling();public void setRecycling(
|
Recycling is used for optimizing performance in iterative
modification or addition of elements in a particular collection.
The elements returned by a recycling collection are not unique
instances; rather they are references to an existing instantiation
cached within the collection that has the attributes of the last
element accessed. Note that recycling is not currently supported
for collection enumeration.
Recycling is useful for iterating through a collection, since it
enables you to remove the cost of the instantiation. For
instance:
AGI.STKObjects.IAgMtoGfxTrackCollection
oTrackCollectionGfx =
(AGI.STKObjects.IAgMtoGfxTrackCollection)AG_MTO.Graphics.Tracks;
oTrackCollectionGfx.Recycling = true;
for (int i = 0 ; i <
oTrackCollectionGfx.Count; ++i)
{
oTrackCollectionGfx[i].Color =
(uint)i;
oTrackCollectionGfx[i].IsVisible
= true;
}
However, it is not useful in a case where you need unique
instantiations, such as:
AGI.STKObjects.IAgMtoTrackCollection oTrackCollection
=
(AGI.STKObjects.IAgMtoTrackCollection)AG_MTO.Tracks;
oTrackCollection.Recycling = true;
STKObjects.IAgMtoTrack oTrack = oTrackCollection.Add(0);
oTrack.Interpolate = true;
STKObjects.IAgMtoTrack oTrack1 = oTrackCollection.Add(1);
oTrack.Interpolate = false;
Assert.IsTrue(oTrack.Interpolate ==
false)
The last line will fail, as oTrack is actually a reference to
oTrack1 (the last element accessed).