feSet Order

Valued Contributor
Valued Contributor

Are IDs in a `Set` object always ordered according to how they are added to the set or by ascending order?

2 REPLIES 2

Re: feSet Order

Phenom
Phenom

The docs don't say explicitly, but the presence of a SORT object - which is a Set object with this comment: " This object however holds the IDs in a prescribed order - normally the order they were added to the object"... suggests the SET object does store your added entities in numerically increasing order.  Besides... here's some test code which proves an feSet stores the ID's in numerically increasing order, not the order in which you select them.  I haven't tried what happens if you have two selection operations without clearing the set in between - you can modify and test:

 

The HTML Clipboard

Sub Main
    Dim App As femap.model
    Set App = feFemap()

    Dim SetObject As femap.Set
    Set SetObject = App.feSet

    Dim nID As Long


    rc = SetObject.Select(FT_NODE,True, "Select nodes in non-numeric order")
    If rc<>-1 Then
        Exit Sub
    End If

    While SetObject.Next()
        nID=SetObject.CurrentID()
        App.feAppMessage(FCM_NORMAL, "Node ID is " + Str$(nID))
    Wend
    
End Sub

Highlighted

Re: feSet Order

Siemens Phenom Siemens Phenom
Siemens Phenom

Set objects are just a list of IDs...always stored in sorted order. You can traverse them in either direction using Next() or Prev(), but internally they are stored from lowest to highest.  Sort objects can contain additional information that you can sort in various ways. Prior to sorting however, they are stored in the order you created them.