/// <summary>
        /// Makes a shallow copy of the current DojoAttendanceEntryCollection.
        /// as the parent object.
        /// </summary>
        /// <returns>DojoAttendanceEntryCollection</returns>
        public DojoAttendanceEntryCollection Clone()
        {
            DojoAttendanceEntryCollection clonedDojoAttendanceEntry = new DojoAttendanceEntryCollection(count);

            lock (this)
            {
                foreach (DojoAttendanceEntry item in this)
                {
                    clonedDojoAttendanceEntry.Add(item);
                }
            }
            return(clonedDojoAttendanceEntry);
        }
        /// <summary>
        /// Makes a deep copy of the current DojoAttendanceEntry.
        /// </summary>
        /// <param name="isolation">Placeholders are used to isolate the
        /// items in the DojoAttendanceEntryCollection from their children.</param>
        public DojoAttendanceEntryCollection Copy(bool isolated)
        {
            DojoAttendanceEntryCollection isolatedCollection = new DojoAttendanceEntryCollection(count);

            lock (this)
            {
                if (isolated)
                {
                    for (int i = 0; i < count; i++)
                    {
                        isolatedCollection.Add(DojoAttendanceEntryArray[i].NewPlaceHolder());
                    }
                }
                else
                {
                    for (int i = 0; i < count; i++)
                    {
                        isolatedCollection.Add(DojoAttendanceEntryArray[i].Copy());
                    }
                }
            }
            return(isolatedCollection);
        }
        //TODO: THIS NEEDS OPTIMIZED WITH A FindTopInstructors(count) METHOD

        public DojoMember FindTopInstructor(DateTime minDate, DateTime maxDate, params DojoMember[] exclusions)
        {
            bool exclusionFlag;

            DojoMember currentInstructor = null;
            int        currentCount      = 0;

            DojoMember topInstructor = null;
            int        topCount      = 0;

            // Return a null value if the array is empty.
            if (this.Count == 0)
            {
                return(null);
            }

            // Clone the array first before the sort to keep
            // array order intact.
            DojoAttendanceEntryCollection temp = this.Clone();

            // Sort array by instructor first to group instructors together,
            // this avoids a messy search routine and allows one quick pass on
            // the array.
            temp.Sort(DojoAttendanceEntryCompareKey.Instructor);

            // Preset the current id to the first entry
            currentInstructor = temp[0].Class.Instructor;

            foreach (DojoAttendanceEntry e in temp)
            {
                if (e.Class.ClassStart < minDate)
                {
                    continue;
                }

                if (e.Class.ClassStart > maxDate)
                {
                    continue;
                }

                // Ignore Classes where student is the teacher
                if (e.Class.Instructor.ID == e.Member.ID)
                {
                    continue;
                }

                if (exclusions != null)
                {
                    exclusionFlag = false;

                    // Ignore Exclusions
                    foreach (DojoMember exclusion in exclusions)
                    {
                        if (exclusion != null &&
                            e.Class.Instructor.ID == exclusion.ID)
                        {
                            exclusionFlag = true;
                        }
                    }

                    if (exclusionFlag)
                    {
                        continue;
                    }
                }

                // TODO: Impliment the following logic!
                // Ignore Classes where student is higher ranked
                // than the instructor.

                // If the current instructor is teaching this class,
                // increase the class count.
                if (e.Class.Instructor.ID == currentInstructor.ID)
                {
                    currentCount++;
                }
                else
                {
                    // If the current instructor has more classes
                    // than the last top instructor, save this instructor
                    // as the new top instructor.
                    if (currentCount > topCount)
                    {
                        topInstructor = currentInstructor;
                        topCount      = currentCount;
                    }

                    // Switch the current instructor to this class's
                    // instructor and reset the current count to 1 since
                    // this class will not be counted on the next loop.
                    currentInstructor = e.Class.Instructor;
                    currentCount      = 1;
                }
            }

            // Test the last instructor's count since it was not
            // processed by the loop.
            if (currentCount > topCount)
            {
                topInstructor = currentInstructor;
            }

            // Return the top instructor
            return(topInstructor);
        }