13693261870
2022-09-16 354b3dbfbffb3df45212a2a44dbbf48b4acc2594
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js"><span id='Ext-util-Queue'>/**
</span> * An internal Queue class.
 * @private
 */
Ext.define('Ext.util.Queue', {
 
<span id='Ext-util-Queue-method-constructor'>    constructor: function() {
</span>        this.clear();
    },
 
<span id='Ext-util-Queue-method-add'>    add : function(obj) {
</span>        var me = this,
            key = me.getKey(obj);
 
        if (!me.map[key]) {
            ++me.length;
            me.items.push(obj);
            me.map[key] = obj;
        }
 
        return obj;
    },
 
<span id='Ext-util-Queue-method-clear'>    /**
</span>     * Removes all items from the collection.
     */
    clear : function(){
        var me = this,
            items = me.items;
 
        me.items = [];
        me.map = {};
        me.length = 0;
 
        return items;
    },
 
<span id='Ext-util-Queue-method-contains'>    contains: function (obj) {
</span>        var key = this.getKey(obj);
 
        return this.map.hasOwnProperty(key);
    },
 
<span id='Ext-util-Queue-method-getCount'>    /**
</span>     * Returns the number of items in the collection.
     * @return {Number} the number of items in the collection.
     */
    getCount : function(){
        return this.length;
    },
 
<span id='Ext-util-Queue-method-getKey'>    getKey : function(obj){
</span>         return obj.id;
    },
 
<span id='Ext-util-Queue-method-remove'>    /**
</span>     * Remove an item from the collection.
     * @param {Object} obj The item to remove.
     * @return {Object} The item removed or false if no item was removed.
     */
    remove : function(obj){
        var me = this,
            key = me.getKey(obj),
            items = me.items,
            index;
 
        if (me.map[key]) {
            index = Ext.Array.indexOf(items, obj);
            Ext.Array.erase(items, index, 1);
            delete me.map[key];
            --me.length;
        }
 
        return obj;
    }
});</pre>
</body>
</html>