BlitzMax

BlitzMax

  • Downloads
  • Docs
  • API
  • Resources
  • About

›ObjectList

BlitzMax API

  • Introduction

BRL

    Audio

    • Introduction
    • TChannel
    • TSound

    AudioSample

    • Introduction
    • TAudioSample
    • TAudioSampleLoader

    Bank

    • Introduction
    • TBank

    BankStream

    • Introduction
    • TBankStream

    Base64

    • Introduction
    • TBase64

    Blitz

    • Introduction
    • TArrayBoundsException
    • TBlitzException
    • TIllegalArgumentException
    • TInvalidEnumException
    • TNullFunctionException
    • TNullMethodException
    • TNullObjectException
    • TOutOfDataException
    • TRuntimeException
    • IIterable
    • IIterator
    • ICloseable

    Clipboard

    • Introduction
    • TClipboard
    • TClipboardOpts
    • TWin32ClipboardOpts
    • TX11ClipboardOpts

    Color

    • Introduction
    • SColor8
  • BRL.D3D7Max2D
  • BRL.D3D9Max2D
  • BRL.DirectSoundAudio
  • BRL.EndianStream
  • Event

    • Introduction
    • TEvent
  • BRL.EventQueue
  • FileSystem

    • Introduction
    • IFileWalker
    • SFileAttributes
  • BRL.FreeAudioAudio
  • BRL.GLGraphics
  • BRL.GLMax2D
  • Glob

    • Introduction
    • EGlobOptions
    • TGlobIter
  • BRL.GNet
  • BRL.Graphics
  • BRL.Hook
  • IO

    • Introduction
    • MaxIO
  • BRL.KeyCodes
  • LinkedList

    • Introduction
    • TList
    • TListEnum
    • TLink

    Map

    • Introduction
    • TMap
  • BRL.Math
  • Max2D

    • Introduction
    • TImage

    MaxLua

    • Introduction
    • TLuaClass
    • TLuaObject

    MaxUnit

    • Introduction
    • TTest
    • TAssert
  • BRL.OGGLoader
  • BRL.OpenALAudio
  • Path

    • Introduction
    • TPath
    • IPathWalker
    • SPathAttributes
    • TPathDirIterator

    Pixmap

    • Introduction
    • TPixmap
    • TPixmapLoader
  • BRL.PolledInput
  • BRL.RamStream
  • Random

    • Introduction
    • TRandomDefault

    RectPacker

    • Introduction
    • EPackingMethod
    • SPackedRect
    • TPackedSheet
    • TRectPacker

    Reflection

    • Introduction
    • TTypeId
    • TMember
    • TConstant
    • TField
    • TGlobal
    • TFunction
    • TMethod
  • BRL.Retro
  • BRL.Socket
  • BRL.SocketStream
  • BRL.StandardIO
  • Stream

    • Introduction
    • TCStream
    • TIO
    • TStream
    • TStreamException
    • TStreamFactory
    • TStreamReadException
    • TStreamWrapper
    • TStreamWriteException

    StringBuilder

    • Introduction
    • TStringBuilder
    • TSplitBuffer
  • BRL.System
  • BRL.SystemDefault
  • BRL.TextStream
  • ThreadPool

    • Introduction
    • TRunnable
    • TThreadPoolExecutor

    Threads

    • Introduction
    • TThread
    • TThreadData
    • TMutex
    • TSemaphore
    • TCondVar

    Time

    • Introduction
    • ETimeUnit
    • TTimeoutException

    Timer

    • Introduction
    • TChrono
  • BRL.TimerDefault
  • Volumes

    • Introduction
    • TVolume
  • BRL.WAVLoader

Pub

  • Pub.FreeJoy
  • Pub.FreeProcess
  • Pub.Glad
  • Pub.Glew
  • Joystick

    • Introduction
    • TJoystickDriver
  • Pub.Lua
  • Pub.OpenAL
  • Pub.OpenGLES
  • StdC

    • Introduction
    • SDateTime
  • Pub.xmmintrin

Collections

    IntMap

    • Introduction
    • TIntMap

    ObjectList

    • Introduction
    • TObjectList
    • TObjectListEnumerator
    • TObjectListReverseEnumerator

    ObjectMap

    • Introduction
    • TObjectMap

    PtrMap

    • Introduction
    • TPtrMap

    StringMap

    • Introduction
    • TStringMap

Crypto

    Digest

    • Introduction
    • TMessageDigest
    • TDigestRegister

    Cipher

    • Introduction
    • TCipher
    • TCipherMode
    • Crypto.AESCipher
    • Crypto.AnubisCipher
    • Crypto.BlowfishCipher
    • Crypto.CamelliaCipher
    • Crypto.Cast5Cipher
    • Crypto.DESCipher
    • Crypto.IdeaCipher
    • Crypto.KasumiCipher
    • Crypto.KhazadCipher
    • Crypto.KSeedCipher
    • Crypto.NoekeonCipher
    • Crypto.SerpentCipher
    • Crypto.SkipjackCipher
    • Crypto.TwofishCipher
    • Crypto.XTeaCipher

    CBCMode

    • Introduction
    • TCBCCipherMode

    CFBMode

    • Introduction
    • TCFBCipherMode

    CTRMode

    • Introduction
    • TCTRCipherMode

    ECBMode

    • Introduction
    • TECBCipherMode

    F8Mode

    • Introduction
    • TF8CipherMode

    LRWMode

    • Introduction
    • TLRWCipherMode

    OFBMode

    • Introduction
    • TOFBCipherMode

    XTSMode

    • Introduction
    • TXTSCipherMode

    Blake2BDigest

    • Introduction
    • TBlake2B_512
    • TBlake2B_384
    • TBlake2B_256
    • TBlake2B_160

    CRC32

    • Introduction
    • TCRC32

    MD5Digest

    • Introduction
    • TMD5

    Ripemd320Digest

    • Introduction
    • TRipemd320

    Ripemd356Digest

    • Introduction
    • TRipemd256

    Ripemd160Digest

    • Introduction
    • TRipemd160

    Ripemd128Digest

    • Introduction
    • TRipemd128

    SHA1Digest

    • Introduction
    • TSHA1

    SHA256Digest

    • Introduction
    • TSHA256

    SHA512Digest

    • Introduction
    • TSHA512

    SHA3Digest

    • Introduction
    • TSHA3_512
    • TSHA3_384
    • TSHA3_256
    • TSHA3_224

    TigerDigest

    • Introduction
    • TTiger

    WhirlpoolDigest

    • Introduction
    • TWhirlpool

    Crypto

    • Introduction
    • TCryptoRandom
    • TCryptoSecretBox
    • TCryptoHash
    • TCryptoSign
    • TCryptoKeyExchange
    • TCryptoKey
    • TCryptoHashKey
    • TCryptoSecretBoxKey
    • TCryptoSignature
    • TCryptoExchangeKeyPair
    • TCryptoSessionKeyPair
    • TCryptoNPacket
    • TCryptoKK1Packet
    • TCryptoKK2Packet
    • TCryptoXX1Packet
    • TCryptoXX2Packet
    • TCryptoXX3Packet
    • TCryptoExchangeState
    • TCryptoPWHashMasterKey
    • TCryptoPWHashStoredKey
    • TCryptoPasswordHash

Math

    Matrix

    • Introduction
    • SMat2D
    • SMat2F
    • SMat2I
    • SMat3D
    • SMat3F
    • SMat3I
    • SMat4D
    • SMat4F
    • SMat4I

    Quaternion

    • Introduction
    • SQuatD
    • SQuatF
    • SQuatI

    Vector

    • Introduction
    • SVec2D
    • SVec2F
    • SVec2I
    • SVec3D
    • SVec3F
    • SVec3I
    • SVec4D
    • SVec4F
    • SVec4I

MaxGUI

  • MaxGUI.MaxGUI
  • MaxGUI.Drivers
  • MaxGUI.Localization
  • MaxGUI.ProxyGadgets
  • MaxGUI.CocoaMaxGUI
  • MaxGUI.Win32MaxGUIEx

Random

    Core

    • Introduction
    • TRandom
  • Random.PRVHASH
  • Random.Secure
  • SFMT

    • Introduction
    • TSFMTRandom
  • Random.Squares
  • Random.Xoshiro

SDL

    SDL

    • Introduction
    • TSDLStream

    SDLSystem

    • Introduction
    • TSDLMultiGesture

    SDLVideo

    • Introduction
    • TSDLDisplay
    • TSDLGLContext
    • TSDLWindow

    SDLRender

    • Introduction
    • TSDLRenderer
    • TSDLTexture

    SDLTimer

    • Introduction
    • TSDLTimer

    SDLHaptic

    • Introduction
    • TSDLHaptic
    • TSDLHapticCondition
    • TSDLHapticConstant
    • TSDLHapticCustom
    • TSDLHapticDirection
    • TSDLHapticEffect
    • TSDLHapticLeftRight
    • TSDLHapticPeriodic
    • TSDLHapticRamp

    SDLSensor

    • Introduction
    • TSDLSensor
  • SDL.SDLFreeAudio
  • SDL.GLSDLMax2D
  • SDL.GL2SDLMax2D
  • SDL.D3D9SDLMax2D
  • SDLVirtualJoystick

    • Introduction
    • TVirtualJoystick

Steam

    SteamSDK

    • Introduction
    • TSteamClient
    • TSteamUtils
    • TSteamUserStats
    • TSteamFriends
    • TSteamUGC
    • ISteamFriendsListener
    • ISteamUGCListener
    • ISteamUserStatsListener
    • ISteamUtilsListener
    • EItemPreviewType
    • EPersonaChange
    • EPersonaState
    • ERemoteStoragePublishedFileVisibility
    • EUGCMatchingUGCType
    • EUGCQuery
    • EUserRestriction
    • EUserUGCList
    • EWorkshopFileType

Text

    CP932Encoding

    • Text.CP932Encoding

    CSV

    • Introduction
    • TCsvParser
    • TCsvHeader
    • TCsvRow
    • TCsvOptions
    • SCsvColumn

    Encoding

    • Text.Encoding

    Format

    • Introduction
    • TFormatter

    Graphviz

    • Introduction
    • TGVGraphviz
    • TAGraph

    Ini

    • Introduction
    • TIni
    • TIniProperty
    • TIniSection

    JConv

    • Introduction
    • TJConv
    • TJConvBuilder
    • TJConvSerializer

    Json

    • Introduction
    • TJSON
    • TJSONObject
    • TJSONString
    • TJSONInteger
    • TJSONReal
    • TJSONBool
    • TJSONArray
    • TJSONNull
    • TJSONError
    • TJSONNumber

    Markdown

    • Introduction
    • TMarkdown
    • IMDRenderer

    Pikchr

    • Introduction
    • EPikChrFlags

    Regex

    • Introduction
    • TRegEx
    • TRegExMatch
    • TRegExOptions
    • TRegExException

    TOML

    • Introduction
    • ETomlNodeType
    • TToml
    • ITomlNode
    • STomlDate
    • STomlDateTime
    • STomlTime
    • TTomlArray
    • TTomlInteger
    • TTomlString
    • TTomlTable
    • TTomlBoolean

    Xml

    • Introduction
    • TxmlDoc
    • TxmlNode
    • TxmlAttribute
Edit

TObjectList

Array-backed Object List

Methods

Method Clear()

Clears the list.

Removes all objects from list.

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the end of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")

' print amount of elements in the list
Print list.Count()

' clear the list and remove all elements
list.Clear()

' print amount of elements in the list
Print list.Count()

' outputs:
' 3
' 0


Method IsEmpty:Int()

Checks if the list is empty.

Returns

True if the list is empty, else False

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the end of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")

' check if the list contains some elements
If list.IsEmpty() Then
    Print "list is empty"
Else
    Print "list contains elements"
EndIf


' outputs:
' list contains elements


Method AddFirst(value:Object)

Adds an object to the start of the list

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the begin of the list
list.AddFirst("one")
list.AddFirst("two")
list.AddFirst("three")

' enumerate all the strings in the list
For Local a:String = EachIn list
    Print a
Next

' outputs:
' three
' two
' one


Method AddLast(value:Object)

Adds an object to the end of the list

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the end of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")

' enumerate all the strings in the list
For Local a:String = EachIn list
    Print a
Next

' outputs:
' one
' two
' three


Method Contains:Int(obj:Object)

Checks if the list contains a value

Returns

True if the list contains obj, else False

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the end of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")

' check if the list contains some elements
If list.Contains("four") Then
    Print "four"
EndIf

If list.Contains("three") Then
    Print "three"
EndIf

' outputs:
' three


Method First:Object()

Returns the first object in the list

Returns Null if the list is empty.

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList


' add some string objects to the end of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")


' request the first element in the list and cast it (back) to a string
' cast is needed as the function returns "object" rather than "string"
Local value:String = String(list.First())

Print value

' outputs:
' one


Method Last:Object()

Returns the last object in the list

Returns Null if the list is empty.

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the end of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")


' request the last element in the list and cast it (back) to a string
' cast is needed as the function returns "object" rather than "string"
Local value:String = String(list.Last())

Print value

' outputs:
' three


Method RemoveFirst:Object()

Removes and returns the first object in the list.

Returns Null if the list is empty.

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the begin of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")

' remove the first element of the list
list.RemoveFirst()

' enumerate all the strings in the list
For Local a:String = EachIn list
    Print a
Next

' outputs:
' two
' three


Method RemoveLast:Object()

Removes and returns the last object in the list.

Returns Null if the list is empty.

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the begin of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")

' remove the last element of the list
list.RemoveLast()

' enumerate all the strings in the list
For Local a:String = EachIn list
    Print a
Next

' outputs:
' one
' two


Method ValueAtIndex:Object(index:Int)

Returns the object at the given index.

Throws an exception if the index is out of range (must be 0..list.Count()-1 inclusive).

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the end of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")

' find the element at the given index and cast it (back) to a string
' cast is needed as the function returns "object" rather than "string"
Local value:String = String(list.ValueAtIndex(1))

Print value 

' outputs:
' two


Method Count:Int()

Counts the list length

Returns

The numbers of objects in the list.

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList


' add some string objects to the end of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")

' print amount of elements in the list
Print list.Count()

' outputs:
' 3


Method Remove:Int(value:Object, removeAll:Int = False, compactOnRemove:Int = True)

Removes an object from the list.

Remove scans the list for the specified value and removes it. By default, only the first found object is removed. Enabling removeAll will result in all instances of value being removed from the list. By default, the list is compacted on each remove. This can be inefficient if removing several objects from a list. Disabling compactOnRemove will skip compaction until either Compact() is called, or the current enumerator completes, or a different list method is called. This mechanism allows for removal of elements during an enumeration.

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the begin of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")

' remove the string "two"
list.Remove("two")

' enumerate all the strings in the list
For Local a:String = EachIn list
    Print a
Next

' outputs:
' one
' three


Method Compact()

Compacts the list.

Use with Remove() and compactOnRemove = False.


Method Swap(list:TObjectList)

Swaps content of two lists while keeping list references intact.

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the end of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")


' create a second object list
Local list2:TObjectList = New TObjectList
list2.AddLast("four")
list2.AddLast("five")
list2.AddLast("six")


' swap the lists
list.Swap(list2)

' enumerate all the strings in the first list
For Local a:String = EachIn list
    Print a
Next

' outputs:
' four
' five
' six


Method Copy:TObjectList()

Creates an identical copy of the list.

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the end of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")

' copy the list elements into another one
Local list2:TObjectList = list.Copy()

' enumerate all the strings in the first list
For Local a:String = EachIn list
    Print a
Next

' enumerate all the strings in the second list
For Local a:String = EachIn list2
    Print a
Next

' outputs:
' one
' two
' three
' one
' two
' three


Method Reverse()

Reverses the order of the list.

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the end of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")

' reverse the list
list.Reverse()

' enumerate all the strings in the list
For Local a:String = EachIn list
    Print a
Next

' outputs:
' three
' two
' one


Method Reversed:TObjectList()

Creates a new list that is the reversed version of this list.

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the end of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")

' create another object list containing the elements in reversed order
Local list2:TObjectList = list.Reversed()

' enumerate all the strings in the first list
For Local a:String = EachIn list
    Print a
Next

' enumerate all the strings in the second list
For Local a:String = EachIn list2
    Print a
Next

' outputs:
' one
' two
' three
' three
' two
' one


Method ToArray:Object[]()

Converts the list to an array

Returns

An array of objects

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the end of the list
list.AddLast("one")
list.AddLast("two")
list.AddLast("three")

' create an array out of the list elements
Local objects:Object[] = list.ToArray() 

' enumerate all the strings in the array
For Local a:String = EachIn objects
    Print a
Next

' outputs:
' one
' two
' three


Method Sort(ascending:Int=True, compareFunc:Int( o1:Object,o2:Object ) )

Sort the list in either ascending (default) or decending order.

User types should implement a Compare method in order to be sorted.

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an object list to hold some objects
Local list:TObjectList = New TObjectList

' add some string objects to the end of the list
list.AddLast("short")
list.AddLast("longer")
list.AddLast("the longest")


' DEFAULT SORT
' sort them (in this case this leads to an alphabetic sort)
' second parameter sets sort to ascending or not
list.Sort(True)

' enumerate all the strings in the list
For Local a:String = EachIn list
    Print a
Next

' outputs:
' longer
' short
' the longest


' CUSTOM SORT
' define a custom compare function
Function MyCompare:Int( o1:Object, o2:Object )
    If Len(String(o1)) < Len(String(o2)) Then
        Return -1 ' o1 before o2
    ElseIf Len(String(o1)) > Len(String(o2)) Then
        Return 1 ' o1 after o2
    Else
        Return 0 ' equal
    EndIf
End Function

' sort them with a custom compare function
list.Sort(True, MyCompare)

' enumerate all the strings in the list
For Local a:String = EachIn list
    Print a
Next

' outputs:
' short
' longer
' the longest


Functions

Function FromArray:TObjectList(arr:Object[])

Creates a list from an array

Returns

A new object list

Example

SuperStrict

Framework Collections.ObjectList
Import Brl.StandardIO

' create an array holding some objects
Local objects:Object[] = ["one", "two", "three"]

' create a object list out of the elements
Local list:TObjectList = TObjectList.FromArray(objects) 

' enumerate all the strings in the list
For Local a:String = EachIn list
    Print a
Next

' outputs:
' one
' two
' three


← IntroductionTObjectListEnumerator →
  • Methods
    • Method Clear()
    • Method IsEmpty:Int()
    • Method AddFirst(value:Object)
    • Method AddLast(value:Object)
    • Method Contains:Int(obj:Object)
    • Method First:Object()
    • Method Last:Object()
    • Method RemoveFirst:Object()
    • Method RemoveLast:Object()
    • Method ValueAtIndex:Object(index:Int)
    • Method Count:Int()
    • Method Remove:Int(value:Object, removeAll:Int = False, compactOnRemove:Int = True)
    • Method Compact()
    • Method Swap(list:TObjectList)
    • Method Copy:TObjectList()
    • Method Reverse()
    • Method Reversed:TObjectList()
    • Method ToArray:Object[]()
    • Method Sort(ascending:Int=True, compareFunc:Int( o1:Object,o2:Object ) )
  • Functions
    • Function FromArray:TObjectList(arr:Object[])
BlitzMax
Docs
Getting StartedDownloadsAbout
Community
Resources
More
GitHubStarChat on Discord
Copyright © 2026 Bruce A Henderson