Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ClassLibrary1
- {
- public class OwnQueue<T>
- {
- private T[] mass;
- int _count = 0, _capacity = 4;
- int _head = 0, _tail = 0;
- public int Count
- {
- get
- {
- return _count;
- }
- set
- {
- if (value > _capacity)
- {
- while(_capacity < value)
- _capacity *= 2;
- T[] newArr = new T[_capacity];
- int j = 0;
- if (_head <= _tail)
- for (int i = _head; i <= _tail; i++)
- newArr[j++] = mass[i];
- if (_head > _tail)
- {
- for (int i = _head; i < _capacity; i++)
- newArr[j++] = mass[i];
- for (int i = 0; i <= _tail; i++)
- newArr[j++] = mass[i];
- }
- mass = newArr;
- _head = 0;
- _tail = _count - 1;
- }
- _count = value;
- }
- }
- public void Enqueue(T elem)
- {
- this.Count++;
- if(_head + 1 >= _capacity)
- {
- }
- }
- public OwnQueue()
- {
- this._count = 0;
- this._capacity = 4;
- }
- }
- }
Advertisement
Advertisement