Project

General

Profile

« Previous | Next » 

Revision 233bba35

Added by Leszek Koltunski 2 days ago

get rid of java.util.LinkedList

View differences:

src/main/java/org/distorted/library/main/InternalStackFrame.kt
21 21

  
22 22
import org.distorted.library.effect.EffectType
23 23
import org.distorted.library.main.InternalMaster.Slave
24
import java.util.LinkedList
25 24

  
26 25
///////////////////////////////////////////////////////////////////////////////////////////////////
27 26
/**
......
35 34
 *
36 35
 * @y.exclude
37 36
 */
38
class InternalStackFrame internal constructor(val taskId: Long)
37
class InternalStackFrame internal constructor(taskId: Long)
39 38
{
40 39
    class Job(var internalObject: InternalObject, var action: Int)
41 40

  
42
    //////////////////////////////////////////////////////////////////
43
    private val mDoneList = LinkedList<InternalObject>() //
44
    private val mToDoMap = HashMap<Long, Job>()          //
45
    private var mTaskId: Long = 0                        //
46
    private var mNextClientID: Long = 0                  // InternalObject
47
    private var mNextSystemID: Long = 0                  //
48

  
49
    //////////////////////////////////////////////////////////////////
50
    var isInitialized: Boolean = false             // DistortedLibrary
51

  
52
    //////////////////////////////////////////////////////////////////
53
    private val mMax: IntArray                          // EffectQueue
54

  
55
    //////////////////////////////////////////////////////////////////
56
    private var mNextEffectsID: Long = 0          // DistortedEffects;
57

  
58
    //////////////////////////////////////////////////////////////////
59
    private var mNextEffectID: Long = 0                     // Effect;
60

  
61
    //////////////////////////////////////////////////////////////////
41
    ////////////////////////////////////////////////////////////////////////
42
    private val mDoneList = ArrayDeque<InternalObject>()                  //
43
    private val mToDoMap = HashMap<Long, Job>()                           //
44
    private var mTaskId: Long = 0                                         //
45
    private var mNextClientID: Long = 0                                   // InternalObject
46
    private var mNextSystemID: Long = 0                                   //
47
    ////////////////////////////////////////////////////////////////////////
48
    var isInitialized: Boolean = false                                    // DistortedLibrary
49
    ////////////////////////////////////////////////////////////////////////
50
    private val mMax: IntArray                                            // EffectQueue
51
    ////////////////////////////////////////////////////////////////////////
52
    private var mNextEffectsID: Long = 0                                  // DistortedEffects;
53
    ////////////////////////////////////////////////////////////////////////
54
    private var mNextEffectID: Long = 0                                   // Effect;
55
    ////////////////////////////////////////////////////////////////////////
62 56
    private val mMapNodeID = HashMap<ArrayList<Long>, InternalNodeData>() // InternalNodeData
63
    private var mNextNodeID: Long = 0
64

  
65
    //////////////////////////////////////////////////////////////////
66
    val mSet: ArrayList<Slave> = ArrayList()          // InternalMaster
67

  
68
    //////////////////////////////////////////////////////////////////
69
    private var mNextQueueID: Long = 1                  // EffectQueue
70

  
71
    ///////////////////////////////////////////////////////////////////////////////////////////////////
72
    val mMap: HashMap<ArrayList<Long>, Long> = HashMap() // maps lists of Effect IDs (longs)
73
                                                         // to a single long - the queue ID.
74
    ///////////////////////////////////////////////////////////////////////////////////////////////////
57
    private var mNextNodeID: Long = 0                                     //
58
    ////////////////////////////////////////////////////////////////////////
59
    val mSet: ArrayList<Slave> = ArrayList()                              // InternalMaster
60
    ////////////////////////////////////////////////////////////////////////
61
    private var mNextQueueID: Long = 1                                    // EffectQueue
62
    ////////////////////////////////////////////////////////////////////////
63
    val mMap: HashMap<ArrayList<Long>, Long> = HashMap()                  // maps lists of Effect IDs (longs)
64
                                                                          // to a single long - the queue ID.
65
    ////////////////////////////////////////////////////////////////////////
75 66
    init
76 67
    {
77 68
        mTaskId = taskId
......
79 70
        EffectType.reset(mMax)
80 71
    }
81 72

  
82
    ///////////////////////////////////////////////////////////////////////////////////////////////////
83 73
    fun getTaskID() = mTaskId
84

  
85
    ///////////////////////////////////////////////////////////////////////////////////////////////////
86
    fun onPause()
87
    {
88
        onPauseGeneric(mDoneList, mToDoMap)
89
    }
90

  
91
    ///////////////////////////////////////////////////////////////////////////////////////////////////
92
    fun toDo()
93
    {
94
        toDoGeneric(mDoneList, mToDoMap)
95
    }
74
    fun onPause()   = onPauseGeneric(mDoneList, mToDoMap)
75
    fun toDo()      = toDoGeneric(mDoneList, mToDoMap)
96 76

  
97 77
    ///////////////////////////////////////////////////////////////////////////////////////////////////
98 78
    fun generateID(type: Int, storage: Int): Long
......
211 191

  
212 192
    companion object
213 193
    {
214
        private val mCommonDoneList = LinkedList<InternalObject>() //
194
        private val mCommonDoneList = ArrayDeque<InternalObject>() //
215 195
        private val mCommonToDoMap = HashMap<Long, Job>()          // Common
216 196
        private var mCommonNextClientID: Long = 0                  // InternalObject
217 197
        private var mCommonNextSystemID: Long = 0                  // (postprocessing)
......
223 203
        }
224 204

  
225 205
        ///////////////////////////////////////////////////////////////////////////////////////////////////
226
        fun onPauseGeneric(list: LinkedList<InternalObject>, map: HashMap<Long, Job>)
206
        fun onPauseGeneric(list: ArrayDeque<InternalObject>, map: HashMap<Long, Job>)
227 207
        {
228 208
            val num = list.size
229 209

  
......
237 217
                    intObject.recreate()
238 218
                }
239 219
            }
240
            catch (ignored: Exception)
220
            catch (_: Exception)
241 221
            {
242 222
                // something else removed an object in the meantime; ignore
243 223
            }
......
250 230
        }
251 231

  
252 232
        ///////////////////////////////////////////////////////////////////////////////////////////////////
253
        fun toDoGeneric(list: LinkedList<InternalObject>, map: HashMap<Long, Job>)
233
        fun toDoGeneric(list: ArrayDeque<InternalObject>, map: HashMap<Long, Job>)
254 234
        {
255 235
            for (key in map.keys)
256 236
            {
......
287 267
        }
288 268

  
289 269
        ///////////////////////////////////////////////////////////////////////////////////////////////////
290
        fun debugListsGeneric(list: LinkedList<InternalObject>, map: HashMap<Long, Job>, frameMarker: String)
270
        fun debugListsGeneric(list: ArrayDeque<InternalObject>, map: HashMap<Long, Job>, frameMarker: String)
291 271
        {
292 272
            DistortedLibrary.logMessage("InternalStackFrame: $frameMarker")
293 273
            DistortedLibrary.logMessage("InternalStackFrame:  Done list:")

Also available in: Unified diff