Android Question Deleting certain items from a list

ThePuiu

Active Member
Licensed User
Longtime User
I have a list like this:
B4X:
Type listObject (idValue As Int, NewVal As Object, OldVal As Object)
Public listObjects As listObject
Public SaveList As List
I would like to delete all the items that have NewVal = OldVal as quickly as possible.
 

lucasheer

Active Member
Licensed User
Longtime User
Probably not the quickest way:

B4X:
            If(SaveList.IsInitialized And SaveList.Size > 0) Then
                For i=SaveList.Size - 1 To 0 Step -1
                    Dim lO As listObject = SaveList.Get(i)
                    If(lO.NewVal = lO.OldVal) Then
                        SaveList.RemoveAt(i)
                    End If
                Next
            End If
 
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
Probably not the quickest way:

B4X:
            If(SaveList.IsInitialized And SaveList.Size > 0) Then
                For i=SaveList.Size - 1 To 0 Step -1
                    Dim lO As listObject = SaveList.Get(i)
                    If(lO.NewVal = lO.OldVal) Then
                        SaveList.RemoveAt(i)
                    End If
                Next
            End If


better than mine!
 
Upvote 0
Top