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 ThreadsUploadOrDownload
- {
- class QueueZ<T> : Queue<T>
- {
- public IEnumerable<T> DequeueList()
- {
- List<T> list = new List<T>();
- for (int i = 0; i < count; i++)
- {
- if (!(this.Count > 0)) break;
- list.Add(base.Dequeue());
- }
- return list;
- }
- private IEnumerable<T> DequeueListAll()
- {
- return this;
- }
- int count;
- public QueueZ(IEnumerable<T> enumerable,int count):base(enumerable)
- {
- this.count = count;
- }
- }
- class SplitArray
- {
- public List<IEnumerable<T>> Start<T>(IEnumerable<T> list,int count)
- {
- List<IEnumerable<T>> result = new List<IEnumerable<T>>();
- var query = new QueueZ<T>(list,list.Count()/count);
- for (int i = 0; i < count; i++)
- {
- result.Add(query.DequeueList());
- }
- if (result.Count > 0) result.Add(query.DequeueList());
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement