/// <summary>
        /// This is the method that is used to index a stream of records
        /// </summary>
        public override void IndexRecords(IEnumerable <StdfRecord> records)
        {
            _AllRecords = new List <StdfRecord>();
            //extents for the current wafer and part
            Extents currentWaferExtents = null;
            Extents currentPartExtents  = null;
            //tells us we're looking for something to confirm the extents are complete (helps us deal with multi-site testing)
            bool waferEnding = false;
            bool partsEnding = false;

            //ends the current wafer extents at the specified index
            void EndWafer(int endIndex)
            {
                currentWaferExtents.EndIndex  = endIndex;
                currentWaferExtents.EndOffset = _AllRecords[endIndex].Offset;
                _WafersMap.AddExtents(currentWaferExtents);
                currentWaferExtents = null;
                waferEnding         = false;
            }

            //ends the current part extents at the specified index
            void EndParts(int endIndex)
            {
                currentPartExtents.EndIndex  = endIndex;
                currentPartExtents.EndOffset = _AllRecords[endIndex].Offset;
                _PartsMap.AddExtents(currentPartExtents);
                currentPartExtents = null;
                partsEnding        = false;
            }

            //loop through the records, building the structure
            foreach (var r in records)
            {
                var index = _AllRecords.Count;
                //look for marker records
                //TODO: does all this checking/casting slow us down too much?
                if (r.GetType() == typeof(Mir))
                {
                    _Mir = (Mir)r;
                }
                else if (r.GetType() == typeof(Mrr))
                {
                    _Mrr = (Mrr)r;
                }
                else if (r.GetType() == typeof(Pcr))
                {
                    _Pcrs.Add((Pcr)r);
                }
                //if we think we're looking for the end of the wafers, and we hit something other than Wrr, we passed the end
                if (waferEnding && r.GetType() != typeof(Wrr))
                {
                    EndWafer(index - 1);
                }
                //if we think we're looking for the end of the parts, and we hit something other than Prr, we passed the end
                if (partsEnding && r.GetType() != typeof(Prr))
                {
                    EndParts(index - 1);
                }
                //when we hit Wrr or Prr, start looking for something else
                if (r.GetType() == typeof(Wrr))
                {
                    waferEnding = true;
                }
                else if (r.GetType() == typeof(Prr))
                {
                    partsEnding = true;
                }
                //if it's a new Pir/Wir, start new extents
                if (r.GetType() == typeof(Pir) && currentPartExtents == null)
                {
                    currentPartExtents = new Extents {
                        StartIndex  = index,
                        StartOffset = r.Offset
                    };
                }
                if (r.GetType() == typeof(Wir) && currentWaferExtents == null)
                {
                    currentWaferExtents = new Extents {
                        StartIndex  = index,
                        StartOffset = r.Offset
                    };
                }
                _AllRecords.Add(r);
            }
            var lastIndex = _AllRecords.Count - 1;

            //end any open wafers/parts at the last index
            if (waferEnding)
            {
                EndWafer(lastIndex);
            }
            if (partsEnding)
            {
                EndParts(lastIndex);
            }
        }