home *** CD-ROM | disk | FTP | other *** search
/ One Click 5 / ONCE005.iso / Interface / it.dig / scripts / __Packages / mx / data / components / datasetclasses / DataSetIterator.as < prev    next >
Encoding:
Text File  |  2006-06-12  |  21.7 KB  |  710 lines

  1. class mx.data.components.datasetclasses.DataSetIterator extends Object implements mx.data.to.ValueListIterator
  2. {
  3.    var _id;
  4.    var _dataset;
  5.    var __filtered;
  6.    var __filterFunc;
  7.    var _options;
  8.    var _startBuff;
  9.    var _endBuff;
  10.    var _rangeOn;
  11.    var _curItemIndex;
  12.    var _hasPrev;
  13.    var _hasNext;
  14.    var _cloned;
  15.    var _bof;
  16.    var _eof;
  17.    var _index;
  18.    var _indexById;
  19.    var _keyList;
  20.    static var Ascending = 32;
  21.    static var CaseInsensitive = Array.CASEINSENSITIVE;
  22.    static var Descending = Array.DESCENDING;
  23.    static var Unique = Array.UNIQUESORT;
  24.    static var Default = 0;
  25.    static var FindInsertId = 0;
  26.    static var FindIndexId = 1;
  27.    static var FindFirstIndexId = 2;
  28.    static var FindLastIndexId = 3;
  29.    static var ItemId = "__ID__";
  30.    function DataSetIterator(id, aDataSet, source)
  31.    {
  32.       super();
  33.       this._id = id;
  34.       this._dataset = aDataSet;
  35.       if(source == undefined)
  36.       {
  37.          this.reset();
  38.       }
  39.       else
  40.       {
  41.          this.__filtered = source.__filtered;
  42.          this.__filterFunc = source.__filterFunc;
  43.          this._options = source._options;
  44.          this._startBuff = source._startBuff;
  45.          this._endBuff = source._endBuff;
  46.          this._rangeOn = source._rangeOn;
  47.          this._curItemIndex = source._curItemIndex;
  48.          this._hasPrev = source._hasPrev;
  49.          this._hasNext = source._hasNext;
  50.          this._cloned = true;
  51.          this._bof = source._bof;
  52.          this._eof = source._eof;
  53.          this._index = source._index;
  54.          this._indexById = source._indexById;
  55.          this._keyList = source._keyList;
  56.       }
  57.    }
  58.    function contains(item)
  59.    {
  60.       var _loc2_ = this._indexById[item[mx.data.components.datasetclasses.DataSetIterator.ItemId]];
  61.       if(this._rangeOn)
  62.       {
  63.          return _loc2_ != undefined && (_loc2_ <= this._eof && _loc2_ >= this._bof);
  64.       }
  65.       return _loc2_ != undefined;
  66.    }
  67.    function first()
  68.    {
  69.       return this.resync(this._bof - 1);
  70.    }
  71.    function find(propValues)
  72.    {
  73.       var _loc2_ = this.findObject(propValues,mx.data.components.datasetclasses.DataSetIterator.FindIndexId);
  74.       if(_loc2_ < 0)
  75.       {
  76.          return null;
  77.       }
  78.       this._curItemIndex = _loc2_;
  79.       return this._index[_loc2_];
  80.    }
  81.    function findFirst(propValues)
  82.    {
  83.       var _loc2_ = this.findObject(propValues,mx.data.components.datasetclasses.DataSetIterator.FindFirstIndexId);
  84.       if(_loc2_ < 0)
  85.       {
  86.          return null;
  87.       }
  88.       this._curItemIndex = _loc2_;
  89.       return this._index[_loc2_];
  90.    }
  91.    function findLast(propValues)
  92.    {
  93.       var _loc2_ = this.findObject(propValues,mx.data.components.datasetclasses.DataSetIterator.FindLastIndexId);
  94.       if(_loc2_ < 0)
  95.       {
  96.          return null;
  97.       }
  98.       this._curItemIndex = _loc2_;
  99.       return this._index[_loc2_];
  100.    }
  101.    function getCurrentItem()
  102.    {
  103.       return this.resync(this._curItemIndex);
  104.    }
  105.    function getCurrentItemIndex()
  106.    {
  107.       var _loc2_ = this._curItemIndex;
  108.       if(_loc2_ > this._eof)
  109.       {
  110.          _loc2_ = this._eof;
  111.       }
  112.       if(_loc2_ < this._bof)
  113.       {
  114.          _loc2_ = this._bof;
  115.       }
  116.       return _loc2_;
  117.    }
  118.    function getFiltered()
  119.    {
  120.       return this.__filtered;
  121.    }
  122.    function getFilterFunc()
  123.    {
  124.       return this.__filterFunc;
  125.    }
  126.    function getId()
  127.    {
  128.       return this._id;
  129.    }
  130.    function getItemAt(index)
  131.    {
  132.       var _loc2_ = index + this._bof;
  133.       if(_loc2_ <= this._eof)
  134.       {
  135.          return this._index[_loc2_];
  136.       }
  137.       return null;
  138.    }
  139.    function getItemId(index)
  140.    {
  141.       return this._index[this._bof + index][mx.data.components.datasetclasses.DataSetIterator.ItemId];
  142.    }
  143.    function getItemIndex(item)
  144.    {
  145.       return this._indexById[item[mx.data.components.datasetclasses.DataSetIterator.ItemId]] - this._bof;
  146.    }
  147.    function getLength()
  148.    {
  149.       if(this.isEmpty())
  150.       {
  151.          return 0;
  152.       }
  153.       return this._eof - this._bof + 1;
  154.    }
  155.    function getSortInfo()
  156.    {
  157.       return {options:this._options,keyList:this._keyList};
  158.    }
  159.    function hasNext()
  160.    {
  161.       return this._hasNext;
  162.    }
  163.    function hasPrevious()
  164.    {
  165.       return this._hasPrev;
  166.    }
  167.    function isEmpty()
  168.    {
  169.       return this._eof < 0;
  170.    }
  171.    function last()
  172.    {
  173.       return this.resync(this._eof + 1);
  174.    }
  175.    function modelChanged(eventObj)
  176.    {
  177.       var _loc4_ = false;
  178.       if(this._options == mx.data.components.datasetclasses.DataSetIterator.Default && !this.__filtered)
  179.       {
  180.          this._index = this._dataset.__items;
  181.          this._indexById = this._dataset._itemIndexById;
  182.          if(eventObj.eventName == "removeItems" && this._curItemIndex > this._index.length - 1)
  183.          {
  184.             this._curItemIndex = this._curItemIndex - 1;
  185.          }
  186.          _loc4_ = eventObj.eventName != "updateField";
  187.       }
  188.       else if(!this._cloned)
  189.       {
  190.          var _loc9_ = undefined;
  191.          if(eventObj.eventName == "removeItems")
  192.          {
  193.             var _loc7_ = undefined;
  194.             var _loc6_ = eventObj.removedIDs;
  195.             if(eventObj.firstItem == 0 && eventObj.lastItem == this._index.length)
  196.             {
  197.                this._index.splice(0,eventObj.lastItem);
  198.             }
  199.             else
  200.             {
  201.                var _loc2_ = 0;
  202.                while(_loc2_ < _loc6_.length)
  203.                {
  204.                   _loc7_ = _loc6_[_loc2_];
  205.                   this._index.splice(this._indexById[_loc7_],1);
  206.                   _loc2_ = _loc2_ + 1;
  207.                }
  208.             }
  209.             this.rebuildIndexById();
  210.             _loc4_ = true;
  211.          }
  212.          else if(eventObj.eventName == "addItems")
  213.          {
  214.             var _loc8_ = this._dataset.__items;
  215.             _loc2_ = eventObj.firstItem;
  216.             while(_loc2_ <= eventObj.lastItem)
  217.             {
  218.                _loc9_ = _loc8_[_loc2_];
  219.                var _loc5_ = _loc2_;
  220.                if(!this.__filtered || this.__filterFunc(_loc9_))
  221.                {
  222.                   if(this._options != mx.data.components.datasetclasses.DataSetIterator.Default)
  223.                   {
  224.                      _loc5_ = this.findObject(_loc9_,mx.data.components.datasetclasses.DataSetIterator.FindInsertId);
  225.                   }
  226.                   this._index.splice(_loc5_,0,_loc9_);
  227.                   this.rebuildIndexById();
  228.                   _loc4_ = true;
  229.                }
  230.                _loc2_ = _loc2_ + 1;
  231.             }
  232.          }
  233.          else if(eventObj.eventName == "updateField")
  234.          {
  235.             _loc2_ = 0;
  236.             while(_loc2_ < this._keyList.length && !_loc4_)
  237.             {
  238.                _loc4_ = this._keyList[_loc2_] == eventObj.fieldName;
  239.                _loc2_ = _loc2_ + 1;
  240.             }
  241.             if(_loc4_)
  242.             {
  243.                _loc9_ = this._dataset.__items[eventObj.firstItem];
  244.                this._index.splice(this._indexById[_loc9_[mx.data.components.datasetclasses.DataSetIterator.ItemId]],1);
  245.                var _loc10_ = this.findObject(_loc9_,mx.data.components.datasetclasses.DataSetIterator.FindInsertId);
  246.                this._index.splice(_loc10_,0,_loc9_);
  247.                this.rebuildIndexById();
  248.             }
  249.          }
  250.       }
  251.       if(_loc4_)
  252.       {
  253.          this.recalcEndPoints();
  254.       }
  255.       return _loc4_;
  256.    }
  257.    function setFiltered(value)
  258.    {
  259.       var _loc2_ = 0;
  260.       if(this.__filtered != value)
  261.       {
  262.          _loc2_ = this.internalFilterItems(value);
  263.          this.__filtered = value;
  264.       }
  265.       return _loc2_;
  266.    }
  267.    function setFilterFunc(value)
  268.    {
  269.       var _loc2_ = 0;
  270.       this.__filterFunc = value;
  271.       if(this.__filterFunc == null && this.__filtered)
  272.       {
  273.          return this.internalFilterItems(false);
  274.       }
  275.       if(this.__filtered)
  276.       {
  277.          this.internalFilterItems(false);
  278.          _loc2_ = this.internalFilterItems(true);
  279.       }
  280.       return _loc2_;
  281.    }
  282.    function skip(offset)
  283.    {
  284.       return this.resync(this._curItemIndex + offset);
  285.    }
  286.    function next()
  287.    {
  288.       return this.skip(1);
  289.    }
  290.    function previous()
  291.    {
  292.       return this.skip(-1);
  293.    }
  294.    function removeRange()
  295.    {
  296.       if(this._rangeOn)
  297.       {
  298.          this._rangeOn = false;
  299.          this.recalcEndPoints();
  300.       }
  301.    }
  302.    function reset()
  303.    {
  304.       this.__filtered = false;
  305.       this.__filterFunc = null;
  306.       this._options = mx.data.components.datasetclasses.DataSetIterator.Default;
  307.       this._startBuff = null;
  308.       this._endBuff = null;
  309.       this._rangeOn = false;
  310.       this._cloned = false;
  311.       this._index = this._dataset.__items;
  312.       this._indexById = this._dataset._itemIndexById;
  313.       this.resetEndPoints();
  314.       this._curItemIndex = this._bof;
  315.       this._hasPrev = false;
  316.       this._hasNext = this._curItemIndex < this._eof;
  317.    }
  318.    function setRange(startValues, endValues)
  319.    {
  320.       this.checkSort();
  321.       this.resetEndPoints();
  322.       this._rangeOn = true;
  323.       this._startBuff = startValues;
  324.       this._endBuff = endValues;
  325.       this.recalcEndPoints();
  326.    }
  327.    function setSortOptions(options)
  328.    {
  329.       if(this._options != mx.data.components.datasetclasses.DataSetIterator.Default)
  330.       {
  331.          if((options & mx.data.components.datasetclasses.DataSetIterator.Ascending) == mx.data.components.datasetclasses.DataSetIterator.Ascending && (this._options & mx.data.components.datasetclasses.DataSetIterator.Descending) == mx.data.components.datasetclasses.DataSetIterator.Descending)
  332.          {
  333.             this._options ^= mx.data.components.datasetclasses.DataSetIterator.Descending;
  334.          }
  335.          this._options |= !this.hasNumericKey() ? 0 : Array.NUMERIC;
  336.          this._options |= options;
  337.          this.internalSort();
  338.          this.first();
  339.          this.recalcEndPoints();
  340.       }
  341.    }
  342.    function sortOn(propList, options)
  343.    {
  344.       this._options = options != undefined ? options : mx.data.components.datasetclasses.DataSetIterator.Ascending;
  345.       this._keyList = propList;
  346.       this._rangeOn = false;
  347.       this._options |= !this.hasNumericKey() ? 0 : Array.NUMERIC;
  348.       this.internalSort();
  349.       this.first();
  350.       this.recalcEndPoints();
  351.    }
  352.    function checkSort()
  353.    {
  354.       if(this._options == mx.data.components.datasetclasses.DataSetIterator.Default)
  355.       {
  356.          throw new mx.data.components.datasetclasses.DataSetError("Operation not applicable when no sort has been defined. Error for iterator \'" + this._id + "\'.");
  357.       }
  358.    }
  359.    function checkError(a)
  360.    {
  361.       if(typeof a == "number")
  362.       {
  363.          throw new mx.data.components.datasetclasses.DataSetError("Sort failed with the following error \'" + mx.utils.ErrorStrings.getPlayerError(a) + "\'");
  364.       }
  365.    }
  366.    function compareValues(a, b)
  367.    {
  368.       if(a == null && b == null)
  369.       {
  370.          return 0;
  371.       }
  372.       if(a == null)
  373.       {
  374.          return 1;
  375.       }
  376.       if(b == null)
  377.       {
  378.          return -1;
  379.       }
  380.       if(a < b)
  381.       {
  382.          return -1;
  383.       }
  384.       if(a > b)
  385.       {
  386.          return 1;
  387.       }
  388.       return 0;
  389.    }
  390.    function comparePropList(alist, blist, ci)
  391.    {
  392.       var _loc5_ = undefined;
  393.       var _loc6_ = 0;
  394.       var _loc4_ = 0;
  395.       var _loc2_ = undefined;
  396.       var _loc3_ = undefined;
  397.       while(_loc6_ == 0 && _loc4_ < this._keyList.length)
  398.       {
  399.          _loc5_ = this._keyList[_loc4_];
  400.          _loc2_ = alist[_loc5_];
  401.          _loc3_ = blist[_loc5_];
  402.          if(ci && typeof _loc2_ == "string")
  403.          {
  404.             _loc2_ = _loc2_.toLowerCase();
  405.             _loc3_ = _loc3_.toLowerCase();
  406.          }
  407.          _loc6_ = this.compareValues(_loc2_,_loc3_);
  408.          _loc4_ = _loc4_ + 1;
  409.       }
  410.       return _loc6_;
  411.    }
  412.    function hasNumericKey()
  413.    {
  414.       var _loc3_ = this._index[0];
  415.       var _loc2_ = 0;
  416.       while(_loc2_ < this._keyList.length)
  417.       {
  418.          if(typeof _loc3_[this._keyList[_loc2_]] == "number")
  419.          {
  420.             return true;
  421.          }
  422.          _loc2_ = _loc2_ + 1;
  423.       }
  424.       return false;
  425.    }
  426.    function filterIndex()
  427.    {
  428.       var _loc7_ = new Array();
  429.       var _loc3_ = undefined;
  430.       var _loc4_ = false;
  431.       var _loc6_ = 0;
  432.       var _loc8_ = undefined;
  433.       var _loc5_ = 0;
  434.       this._indexById = new Array();
  435.       var _loc2_ = 0;
  436.       while(_loc2_ < this._index.length)
  437.       {
  438.          _loc3_ = this._index[_loc2_];
  439.          try
  440.          {
  441.             _loc4_ = this.__filterFunc(_loc3_);
  442.          }
  443.          finally
  444.          {
  445.          }
  446.          if(_loc4_)
  447.          {
  448.             _loc7_.push(_loc3_);
  449.             this._indexById[_loc3_[mx.data.components.datasetclasses.DataSetIterator.ItemId]] = _loc5_;
  450.             _loc5_ = _loc5_ + 1;
  451.          }
  452.          else
  453.          {
  454.             _loc6_ = _loc6_ - 1;
  455.          }
  456.          _loc2_ = _loc2_ + 1;
  457.       }
  458.       this._index = _loc7_;
  459.       this._cloned = false;
  460.       return _loc6_;
  461.    }
  462.    function findObject(propInfo, mode)
  463.    {
  464.       var _loc19_ = propInfo[mx.data.components.datasetclasses.DataSetIterator.ItemId];
  465.       if(_loc19_ != undefined && mode != mx.data.components.datasetclasses.DataSetIterator.FindInsertId)
  466.       {
  467.          var _loc18_ = this._indexById[_loc19_];
  468.          if(this._rangeOn && (_loc18_ > this._eof || _loc18_ < this._bof))
  469.          {
  470.             _loc18_ = -1;
  471.          }
  472.          return _loc18_;
  473.       }
  474.       this.checkSort();
  475.       var _loc3_ = false;
  476.       var _loc17_ = mode == mx.data.components.datasetclasses.DataSetIterator.FindIndexId || mode == mx.data.components.datasetclasses.DataSetIterator.FindFirstIndexId || mode == mx.data.components.datasetclasses.DataSetIterator.FindLastIndexId;
  477.       var _loc15_ = (this._options & mx.data.components.datasetclasses.DataSetIterator.Unique) != mx.data.components.datasetclasses.DataSetIterator.Unique;
  478.       var _loc16_ = false;
  479.       var _loc2_ = 0;
  480.       var _loc6_ = !_loc17_ ? 0 : this._bof;
  481.       var _loc7_ = !_loc17_ ? this._index.length - 1 : this._eof;
  482.       var _loc14_ = null;
  483.       var _loc12_ = 1;
  484.       var _loc13_ = (this._options & mx.data.components.datasetclasses.DataSetIterator.Descending) == mx.data.components.datasetclasses.DataSetIterator.Descending;
  485.       var _loc9_ = (this._options & mx.data.components.datasetclasses.DataSetIterator.CaseInsensitive) == mx.data.components.datasetclasses.DataSetIterator.CaseInsensitive;
  486.       while(!_loc16_ && _loc6_ <= _loc7_)
  487.       {
  488.          _loc2_ = Math.round((_loc6_ + _loc7_) / 2);
  489.          _loc14_ = this._index[_loc2_];
  490.          _loc12_ = this.comparePropList(propInfo,_loc14_,_loc9_);
  491.          switch(_loc12_)
  492.          {
  493.             case -1:
  494.                if(_loc13_)
  495.                {
  496.                   _loc6_ = _loc2_ + 1;
  497.                }
  498.                else
  499.                {
  500.                   _loc7_ = _loc2_ - 1;
  501.                }
  502.                break;
  503.             case 0:
  504.                _loc16_ = true;
  505.                if(!_loc15_ && mode == mx.data.components.datasetclasses.DataSetIterator.FindInsertId)
  506.                {
  507.                   throw new mx.data.components.datasetclasses.DataSetError("Duplicate key specified. Error for index \'" + this._id + "\' on dataset \'" + this._dataset._name + "\'.");
  508.                }
  509.                if(_loc15_ && _loc17_)
  510.                {
  511.                   switch(mode)
  512.                   {
  513.                      case mx.data.components.datasetclasses.DataSetIterator.FindIndexId:
  514.                         _loc3_ = true;
  515.                         break;
  516.                      case mx.data.components.datasetclasses.DataSetIterator.FindFirstIndexId:
  517.                         _loc3_ = _loc2_ == _loc6_;
  518.                         var _loc8_ = null;
  519.                         var _loc5_ = _loc2_ - 1;
  520.                         var _loc4_ = true;
  521.                         while(_loc4_ && !_loc3_ && _loc5_ >= _loc6_)
  522.                         {
  523.                            _loc8_ = this._index[_loc5_];
  524.                            _loc4_ = this.comparePropList(propInfo,_loc8_,_loc9_) == 0;
  525.                            if(!_loc4_ || _loc4_ && _loc5_ == _loc6_)
  526.                            {
  527.                               _loc3_ = true;
  528.                               _loc2_ = _loc5_ + (!_loc4_ ? 1 : 0);
  529.                            }
  530.                            _loc5_ = _loc5_ - 1;
  531.                         }
  532.                         break;
  533.                      case mx.data.components.datasetclasses.DataSetIterator.FindLastIndexId:
  534.                         _loc3_ = _loc2_ == _loc7_;
  535.                         _loc8_ = null;
  536.                         _loc5_ = _loc2_ + 1;
  537.                         _loc4_ = true;
  538.                         while(_loc4_ && !_loc3_ && _loc5_ <= _loc7_)
  539.                         {
  540.                            _loc8_ = this._index[_loc5_];
  541.                            _loc4_ = this.comparePropList(propInfo,_loc8_,_loc9_) == 0;
  542.                            if(!_loc4_ || _loc4_ && _loc5_ == _loc7_)
  543.                            {
  544.                               _loc3_ = true;
  545.                               _loc2_ = _loc5_ - (!_loc4_ ? 1 : 0);
  546.                            }
  547.                            _loc5_ = _loc5_ + 1;
  548.                         }
  549.                   }
  550.                }
  551.                else
  552.                {
  553.                   _loc3_ = true;
  554.                }
  555.                break;
  556.             case 1:
  557.                if(_loc13_)
  558.                {
  559.                   _loc7_ = _loc2_ - 1;
  560.                }
  561.                else
  562.                {
  563.                   _loc6_ = _loc2_ + 1;
  564.                }
  565.                break;
  566.          }
  567.       }
  568.       if(!_loc3_ && _loc17_)
  569.       {
  570.          return -1;
  571.       }
  572.       if(_loc13_)
  573.       {
  574.          return _loc12_ >= 0 ? _loc2_ : _loc2_ + 1;
  575.       }
  576.       return _loc12_ <= 0 ? _loc2_ : _loc2_ + 1;
  577.    }
  578.    function internalFilterItems(value)
  579.    {
  580.       var _loc2_ = 0;
  581.       if(value && this.__filterFunc != null)
  582.       {
  583.          _loc2_ = this.filterIndex();
  584.       }
  585.       else
  586.       {
  587.          this.unfilterIndex();
  588.          if(this._options != mx.data.components.datasetclasses.DataSetIterator.Default)
  589.          {
  590.             this.internalSort();
  591.          }
  592.          _loc2_ = this._index.length;
  593.       }
  594.       this.recalcEndPoints();
  595.       return _loc2_;
  596.    }
  597.    function internalSort()
  598.    {
  599.       var _loc5_ = (this._options & mx.data.components.datasetclasses.DataSetIterator.Ascending) != mx.data.components.datasetclasses.DataSetIterator.Ascending ? this._options : this._options ^ mx.data.components.datasetclasses.DataSetIterator.Ascending;
  600.       if(this._cloned)
  601.       {
  602.          this._cloned = false;
  603.          var _loc3_ = this._index.sortOn(Object(this._keyList),_loc5_ | Array.RETURNINDEXEDARRAY);
  604.          this.checkError(_loc3_);
  605.          var _loc4_ = new Array();
  606.          var _loc2_ = 0;
  607.          while(_loc2_ < _loc3_.length)
  608.          {
  609.             _loc4_.push(this._index[_loc3_[_loc2_]]);
  610.             _loc2_ = _loc2_ + 1;
  611.          }
  612.          this._index = _loc4_;
  613.       }
  614.       else
  615.       {
  616.          this.checkError(this._index.sortOn(Object(this._keyList),_loc5_));
  617.       }
  618.       this.rebuildIndexById();
  619.    }
  620.    function recalcEndPoints()
  621.    {
  622.       this.resetEndPoints();
  623.       if(this._rangeOn)
  624.       {
  625.          var _loc3_ = (this._options & mx.data.components.datasetclasses.DataSetIterator.Descending) == mx.data.components.datasetclasses.DataSetIterator.Descending;
  626.          var _loc2_ = undefined;
  627.          if(_loc3_)
  628.          {
  629.             _loc2_ = this._startBuff;
  630.             this._startBuff = this._endBuff;
  631.             this._endBuff = _loc2_;
  632.          }
  633.          this._bof = this.findObject(this._startBuff,mx.data.components.datasetclasses.DataSetIterator.FindFirstIndexId);
  634.          if(this._bof >= 0)
  635.          {
  636.             this._eof = this.findObject(this._endBuff,mx.data.components.datasetclasses.DataSetIterator.FindLastIndexId);
  637.             if(this._eof < 0)
  638.             {
  639.                this._bof = 0;
  640.             }
  641.          }
  642.          else
  643.          {
  644.             this._eof = this._bof - 1;
  645.          }
  646.          this._curItemIndex = this._bof - 1;
  647.       }
  648.       this.resync(this._curItemIndex);
  649.    }
  650.    function resetEndPoints()
  651.    {
  652.       this._eof = this._index.length - 1;
  653.       this._bof = 0;
  654.    }
  655.    function rebuildIndexById()
  656.    {
  657.       this._indexById = new Array();
  658.       var _loc2_ = 0;
  659.       while(_loc2_ < this._index.length)
  660.       {
  661.          this._indexById[this._index[_loc2_][mx.data.components.datasetclasses.DataSetIterator.ItemId]] = _loc2_;
  662.          _loc2_ = _loc2_ + 1;
  663.       }
  664.    }
  665.    function resync(newPos)
  666.    {
  667.       if(this._eof < this._bof)
  668.       {
  669.          this._hasNext = false;
  670.          this._hasPrev = false;
  671.          this._curItemIndex = this._eof;
  672.          return null;
  673.       }
  674.       if(newPos >= this._eof)
  675.       {
  676.          this._hasNext = false;
  677.          this._hasPrev = true;
  678.          if(newPos == this._eof)
  679.          {
  680.             this._curItemIndex = this._eof;
  681.             return this._index[this._eof];
  682.          }
  683.          this._curItemIndex = this._eof + 1;
  684.          return null;
  685.       }
  686.       if(newPos <= this._bof)
  687.       {
  688.          this._hasPrev = false;
  689.          this._hasNext = true;
  690.          if(newPos == this._bof)
  691.          {
  692.             this._curItemIndex = this._bof;
  693.             return this._index[this._bof];
  694.          }
  695.          this._curItemIndex = this._bof - 1;
  696.          return null;
  697.       }
  698.       this._curItemIndex = newPos;
  699.       this._hasNext = true;
  700.       this._hasPrev = true;
  701.       return this._index[this._curItemIndex];
  702.    }
  703.    function unfilterIndex()
  704.    {
  705.       this._index = this._dataset.__items;
  706.       this._indexById = this._dataset._itemIndexById;
  707.       this._cloned = true;
  708.    }
  709. }
  710.