private void AddToBuffer(int TimeStep, PhreaticPotentialData PC)
        {
            if (AccessList.Count > DFS3.MaxEntriesInBuffer)
            {
                _bufferedData.Remove(AccessList.First());
                AccessList.RemoveFirst();
            }

            _bufferedData.Add(TimeStep, PC);
        }
    private void AddToBuffer(int TimeStep, PhreaticPotentialData PC)
    {
      if (AccessList.Count > DFS3.MaxEntriesInBuffer)
      {
        _bufferedData.Remove(AccessList.First());
        AccessList.RemoveFirst();
      }

      _bufferedData.Add(TimeStep, PC);

    }
 /// <summary>
 /// Returns the phreatic potential.
 /// Note that it returns a reference to a matrix
 /// </summary>
 /// <param name="TimeStep"></param>
 /// <returns></returns>
 public IMatrix3d TimeData(int TimeStep)
 {
   PhreaticPotentialData PC;
   lock (_lock)
   {
     if (!_bufferedData.TryGetValue(TimeStep, out PC))
     {
       count++;
       PC = new PhreaticPotentialData(_potential.TimeData(TimeStep), _bottomOfCell.Data, _thicknessOfCell.Data, _phreaticFactor, _deleteValue);
       AccessList.AddLast(TimeStep);
       AddToBuffer(TimeStep, PC);
     }
   AccessList.Remove(TimeStep);
   AccessList.AddLast(TimeStep);
   }
   return PC;
 }
        /// <summary>
        /// Returns the phreatic potential.
        /// Note that it returns a reference to a matrix
        /// </summary>
        /// <param name="TimeStep"></param>
        /// <returns></returns>
        public IMatrix3d TimeData(int TimeStep)
        {
            PhreaticPotentialData PC;

            lock (_lock)
            {
                if (!_bufferedData.TryGetValue(TimeStep, out PC))
                {
                    count++;
                    PC = new PhreaticPotentialData(_potential.TimeData(TimeStep), _bottomOfCell.Data, _thicknessOfCell.Data, _phreaticFactor, _deleteValue);
                    AccessList.AddLast(TimeStep);
                    AddToBuffer(TimeStep, PC);
                }
                AccessList.Remove(TimeStep);
                AccessList.AddLast(TimeStep);
            }
            return(PC);
        }