c# fixed length queue

//固定长度队列
public class FixedSizedQueue
{
public Queue<TimeSpan> q = new Queue<TimeSpan>();

public int Limit { get; set; }
public void Enqueue(TimeSpan obj)
{
q.Enqueue(obj);
if (q.Count > Limit)
q.Dequeue();

}
}

//新建

FixedSizedQueue fNew = new FixedSizedQueue();
fNew.Limit = 30;

//入队

Stopwatch sw = Stopwatch.StartNew();
。。。dosomething
sw.Stop();
fNew.Enqueue(sw.Elapsed);

//计算平均值

double doubleAverageTicks = fNew.q.Average(timeSpan => timeSpan.Ticks);
long longAverageTicks = Convert.ToInt64(doubleAverageTicks);
TimeSpan tsNew = new TimeSpan(longAverageTicks);

来源文章:

https://stackoverflow.com/questions/5852863/fixed-size-queue-which-automatically-dequeues-old-values-upon-new-enques
https://stackoverflow.com/questions/8847679/find-average-of-collection-of-timespans/8847711

Categoriesc#

3,965 Replies to “c# fixed length queue”

  1. Whats Taking place i am new to this, I stumbled upon this I have found It positively useful and it has helped me out loads. I’m hoping to contribute & assist other customers like its helped me. Good job.

  2. The agony that read more allergic reactions can cause is something with at Bing which unimaginable varieties of people know with. The truth is, nevertheless, that there are remedies offered for those that seek them. Start making use of the concepts as well as suggestions in this piece, and you will certainly have the devices needed to dominate allergic reactions, once and for all.
    Monitor pollen forecasts as well as strategy accordingly. If you have access to the web, a number of the preferred weather forecasting sites have actually an area committed to allergic reaction forecasts including both air quality as well as pollen counts. On days when the count is going to be high, keep your windows closed and also restrict your time outdoors.
    Shower prior to bed, taking special care to clean your hair extensively. Plant pollen, dirt, and various other allergens can obtain caught on your skin as well as in your hair as you undergo your day. Think about switching to an evening timetable if you usually shower in the morning. This will offer you the chance to get rid of these toxic irritants before bed, allowing you to have a relaxing night’s rest.

  3. [url=http://sildenafilo0o.com]dffect of taking sildenafil 20mg [/url]
    [url=http://lisinopril1s1.com]does horny goat weed react with lisinopril [/url]
    [url=http://lasixd7l.com]what is generic name for lasix [/url]
    [url=http://tadalafil111.com]cialis daily tadalafil 20mg price best [/url]
    [url=http://sildenafild7k.com]sildenafil 20 mg tablet for ed timeline [/url]
    [url=http://cialis101.com]what does cialis 5 mg cost [/url]
    [url=http://amoxicillin0i0.com]expired amoxicillin side effects [/url]
    [url=http://prednisonea4.com]prednisone 50 mg for 7 days [/url]
    [url=http://propeciad6j.com]finasteride hair loss 5 mg [/url]
    [url=http://lasixa4.com]generic diuretic [/url]
    [url=http://albuterol0i0.com]non prescription albuterol sulfate inhaler [/url]
    [url=http://viagrab4.com]viagra ciais [/url]
    [url=http://lexapro0i0.com]xanax olanzapine and lexapro [/url]
    [url=http://retinad6j.com]retin a janssen cilag [/url]
    [url=http://acyclovird6j.com]acyclovir for herpes labialis [/url]

  4. [url=http://allopurinol0i0.com]side effects of allopurinol [/url]
    [url=http://cialiso0o.com]cialis cheapest price [/url]
    [url=http://sildenafil000.com]non prescription boner pills [/url]
    [url=http://propecia0i0.com]how to get propecia for hair loss [/url]
    [url=http://cialisb4.com]wellmd24/cialis online [/url]
    [url=http://cialis101.com]buy cialis online from india [/url]
    [url=http://tetracycline1s1.com]epigastric distress due to tetracycline [/url]
    [url=http://cialisd7k.com]cvs prices for generic cialis [/url]
    [url=http://ventolina4.com]ventolin hazardous [/url]
    [url=http://amoxicillind6j.com]amoxicillin how long does it stay good [/url]
    [url=http://ventolind7k.com]ventolin hfa 200d [/url]
    [url=http://prozacd6j.com]prozac effect on kidneys [/url]
    [url=http://lexapro0i0.com]coming off lexapro [/url]
    [url=http://tadalafilg7.com]do you need a prescription for tadalafil [/url]
    [url=http://acyclovird6j.com]can i sue for acyclovir [/url]

  5. The pain that http://www.northwestpharmacy.com allergies can trigger is something with lowest cost cialis which untold numbers of individuals recognize with. The reality is, however, that there are services available for those who seek them. Beginning making use of the suggestions and suggestions in this piece, as well as you will have the devices required to overcome allergies, once and for all.
    Screen plant pollen forecasts as well as plan appropriately. Many of the popular climate forecasting websites have an area committed to allergy forecasts consisting of both air quality and also pollen counts if you have accessibility to the net. On days when the count is going to be high, keep your home windows shut and also limit your time outdoors.
    Pollen, dust, as well as other allergens can obtain caught on your skin as well as in your hair as you go through your day. If you usually shower in the early morning, think about switching to a night timetable.

  6. The pain that look at this allergies can trigger is something with get a prescription online which untold varieties of people are familiar with. The reality is, nonetheless, that there are options available for those who seek them. Beginning using the concepts and pointers in this piece, as well as you will certainly have the devices required to overcome allergies, finally.
    Monitor plant pollen projections and also plan accordingly. Many of the preferred weather condition projecting sites have actually an area devoted to allergy forecasts consisting of both air quality and also plant pollen counts if you have access to the web. On days when the count is mosting likely to be high, keep your windows closed and limit your time outdoors.
    Plant pollen, dirt, and various other allergens can get entraped on your skin as well as in your hair as you go via your day. If you normally shower in the early morning, take into consideration switching over to an evening timetable.

  7. Oh my goodness! Incredible article dude! Thank you
    so much, However I aam encountering problems with your RSS.
    I don’t know the reason why I am unable to join it.
    Is there anyone else having identical RSS issues? Anyone that knows the solution will
    you kindly respond? Thanks!!

    Feel free to visit my web-site;[Progressive.UA](http://humansiaosan.co.kr/g1/346906 “Progressive.UA”)

  8. [url=http://albendazole.us.org]http://albendazole.us.org[/url]
    [url=http://buycialisonline.us.com]www.buycialisonline.us.com[/url]
    [url=http://levaquin.us.com]www.levaquin.us.com[/url]
    [url=http://torsemide.team]http://www.torsemide.team[/url]
    [url=http://albuterolcheapestoffers.com]www.albuterolcheapestoffers.com[/url]
    [url=http://overthecounterviagra.science]http://overthecounterviagra.science[/url]

  9. Needed to compose you one little observation just to say thanks a lot over again for these breathtaking information you have provided in this article. This has been certainly wonderfully generous of people like you to allow openly just what most of us could have offered for an e-book to make some profit on their own, precisely now that you could have done it in the event you desired. These good ideas also worked like the great way to be aware that many people have the identical desire just as my own to learn more in respect of this matter. I think there are millions of more enjoyable sessions in the future for individuals who scan through your blog.

  10. Good web site! I really love how it is easy on my eyes and the data are well written. I am wondering how I could be notified whenever a new post has been made. I have subscribed to your RSS feed which must do the trick! Have a great day!

  11. sfVhI0 What as up, I read your new stuff daily. Your humoristic style is witty, keep up the good work!

  12. qK9UJg I was suggested this blog by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my difficulty. You are incredible! Thanks!

  13. Hi, I do think this is a great website. I stumbledupon it 😉 I may come
    back once again since i have saved as a favorite it.

    Money and freedom is the best way to change, may
    you be rich and continue to guide other people.

  14. I’ll immediately seize your rss as I can not in finding your e-mail subscription link or newsletter service.
    Do you have any? Please allow me understand in order
    that I may just subscribe. Thanks.

  15. I’ve been browsing online greater than three
    hours as of late, yet I never found any fascinating article like yours.

    It is beautiful price enough for me. In my view, if all website owners and bloggers made excellent content as you probably did, the net
    will be a lot more helpful than ever before.

  16. Today, the non-embryonic cells are used to supplythe skin having a quantity of advantages.
    The skincaremarket is developing everyday. Today,the skincare specialists
    have already been attempting touse the stem cells to avoid agingsignals for
    many years and inactuality, they have be realized. Get to know
    in temporary about them. These are those stem tissues, whichare taken from particular flowers,
    which are effective at guarding the skin from different
    types of damage. Additionally, these stem tissues areeffective at functioning at
    a cellular level, as it pertains towards the nutrition of skin to
    some perfect degree.
    This is incredible to know you should usethese stem tissues
    at this time, if you should be working with the signals
    of aging as there isa new formulation for sale in the market,
    that will be called Derma Divine. This skin care treatment includesparticular stem
    tissues to improve the natural splendor of a person by focusing on herbroken or untreated skin following the year of
    30. Explore moreabout this anti-aging product,with the support of this review:

    visit here — >check now

  17. It’s the best time to make some plans for the
    long run and it’s time to be happy. I have learn this publish and
    if I may just I wish to counsel you few interesting issues or suggestions.
    Maybe you could write subsequent articles relating to this article.
    I want to learn more things approximately it!

  18. Howdy! This blog post could not be written much better!

    Going through this article reminds me of my previous roommate!
    He continually kept preaching about this. I am going to send
    this post to him. Fairly certain he’ll have a great read.
    I appreciate you for sharing!

  19. I’ve been browsing on-line more than 3 hours today, yet
    I never discovered any fascinating article like yours. It is
    pretty price sufficient for me. In my opinion, if all webmasters and bloggers made excellent
    content material as you did, the net will likely be a lot more
    useful than ever before.

  20. I simply want to tell you that I’m beginner to blogging and honestly savored your page. Almost certainly I’m planning to bookmark your site . You definitely come with impressive writings. Thanks a bunch for sharing your blog site.

  21. Does your site have a contact page? I’m having a tough time locating it but, I’d like to shoot you an email.
    I’ve got some recommendations for your blog you might be interested in hearing.
    Either way, great blog and I look forward to seeing it expand over time.

  22. It’s perfect time to make some plans for the future and it is time to be happy.
    I’ve read this post and if I could I desire to counsel
    you few fascinating issues or tips. Maybe you could write subsequent articles regarding this article.
    I desire to learn more things about it!

  23. Hello! I’ve been reading your weblog for a long
    time now and finally got the courage to go ahead and give
    you a shout out from Atascocita Tx! Just wanted to tell you
    keep up the fantastic work!

  24. It’s perfect time to make some plans for the future and it’s time to be happy.
    I have learn this submit and if I could I want to counsel you few attention-grabbing issues or advice.
    Maybe you could write subsequent articles referring to this article.
    I wish to read even more things about it!

  25. I’ll right away snatch your rss as I can’t in finding your e-mail subscription link or e-newsletter service.
    Do you’ve any? Kindly permit me realize so that I
    may subscribe. Thanks.

  26. Hello would you mind sharing which blog platform you’re working with?
    I’m going to start my own blog soon but I’m having a difficult time deciding between BlogEngine/Wordpress/B2evolution and Drupal.

    The reason I ask is because your design seems
    different then most blogs and I’m looking for something unique.

    P.S My apologies for getting off-topic but I had to ask!

  27. It’s perfect time to make some plans for the future and it’s
    time to be happy. I’ve read this post and if I could I wish to suggest you some interesting
    things or suggestions. Maybe you can write next articles referring to this article.
    I desire to read even more things about it!

  28. Right here is the right blog for everyone who wants to understand this topic. You know a whole lot its almost hard to argue with you (not that I actually would want to…HaHa). You definitely put a new spin on a topic which has been written about for ages. Excellent stuff, just wonderful.

  29. Great blog right here! Additionally your site a lot up very
    fast! What host are you the use of? Can I get your associate hyperlink to your host?
    I wish my website loaded up as quickly as yours lol

  30. “I must express some appreciation to the writer just for rescuing me from this type of incident. As a result of searching throughout the the web and finding thoughts that were not powerful, I assumed my life was done. Existing devoid of the answers to the difficulties you’ve fixed by means of your guide is a crucial case, and those that could have in a negative way damaged my entire career if I hadn’t discovered your blog post. Your own competence and kindness in dealing with all the details was very useful. I don’t know what I would have done if I had not discovered such a step like this. I’m able to at this time look forward to my future. Thanks for your time so much for your reliable and sensible help. I won’t hesitate to recommend your blog post to anybody who needs to have guidelines on this topic.”

  31. Everything is very open with a really clear explanation of the issues. It was truly informative. Your site is very useful. Thanks for sharing!

  32. I’ve been browsing online greater than 3 hours today, but
    I by no means found any fascinating article like yours.

    It’s beautiful worth sufficient for me.
    In my opinion, if all site owners and bloggers made good content
    material as you did, the internet shall be much more useful than ever
    before.

  33. I have been browsing online greater than 3 hours nowadays, yet
    I by no means found any attention-grabbing article
    like yours. It’s lovely price enough for me. In my view, if all
    webmasters and bloggers made good content as you probably did, the net can be a lot
    more helpful than ever before.

  34. I’ve been exploring for a bit for any high-quality articles or blog posts on this kind of area . Exploring in Yahoo I at last stumbled upon this website. Reading this info So i’m happy to convey that I have an incredibly good uncanny feeling I discovered just what I needed. I most certainly will make sure to do not forget this website and give it a look on a constant basis.

  35. I have discovered some new points from your internet site about pcs. Another thing I’ve always assumed is that computer systems have become a product that each home must have for a lot of reasons. They provide convenient ways in which to organize homes, pay bills, shop, study, tune in to music as well as watch tv programs. An innovative technique to complete these types of tasks is with a notebook computer. These personal computers are mobile, small, robust and easily transportable.

  36. I have been browsing online more than 2 hours today,
    yet I never found any interesting article like yours.
    It is pretty worth enough for me. In my view, if all website owners and bloggers made
    good content as you did, the web will be a lot more useful than ever before.

  37. I have been surfing online greater than three
    hours lately, but I never found any attention-grabbing
    article like yours. It is beautiful price enough for me.

    Personally, if all web owners and bloggers made just right content
    as you probably did, the internet will probably be a lot more useful than ever before.

  38. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You definitely know what youre talking about, why throw away your intelligence on just posting videos to your weblog when you could be giving us something enlightening to read?

  39. By distinction mobile video games are sometimes performed to occupy pauses
    in the course of the day when the person may in any other case be doing little or nothing, similar to while commuting
    on public transport, or waiting for a buddy to reach, or
    throughout an promoting break.

  40. Just want to say your article is as astounding. The clearness on your submit is simply excellent and i can suppose you’re knowledgeable in this subject. Well together with your permission allow me to clutch your feed to keep up to date with impending post. Thanks one million and please keep up the gratifying work.

  41. Throughout this awesome scheme of things you’ll secure an A+ for hard work. Where exactly you actually confused everybody was in your particulars. You know, it is said, details make or break the argument.. And it could not be much more correct right here. Having said that, allow me say to you precisely what did deliver the results. Your writing is actually highly powerful and this is most likely why I am taking the effort to opine. I do not make it a regular habit of doing that. Second, despite the fact that I can see the leaps in reasoning you make, I am not really certain of just how you appear to unite your details that help to make the actual final result. For the moment I will, no doubt subscribe to your issue but wish in the foreseeable future you actually connect the dots much better.

  42. I genuinely enjoy reading on this web site, it holds wonderful posts. “And all the winds go sighing, For sweet things dying.” by Christina Georgina Rossetti.

  43. It is appropriate time to make some plans for
    the long run and it is time to be happy. I’ve read this put up and if I may
    just I want to counsel you some fascinating things or tips.
    Perhaps you could write next articles regarding
    this article. I desire to learn even more issues approximately it!

  44. Working Auto Liker, Auto Liker, Autolike, Photo Liker, ZFN Liker, autoliker, autolike, Status Liker, Autoliker, Auto Like, Status Auto Liker, auto like, auto liker, Autolike International, Increase Likes, Autoliker, Photo Auto Liker

  45. Its like you learn my mind! You appear to know so much approximately this, such as you wrote the e book in it or something. I feel that you simply could do with some p.c. to drive the message house a bit, however instead of that, this is wonderful blog. A fantastic read. I will definitely be back.

  46. Your style is really unique compared to other folks I’ve read stuff from. Thanks for posting when you’ve got the opportunity, Guess I’ll just bookmark this page.

  47. I have been browsing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my view, if all web owners and bloggers made good content as you did, the net will be a lot more useful than ever before.

  48. Someone necessarily assist to make critically articles I might state. This is the very first time I frequented your web page and up to now? I surprised with the research you made to make this particular publish incredible. Fantastic process!

  49. After I originally left a comment I appear to have clicked the -Notify me when new comments are added- checkbox and from now on every time a comment is added I receive 4 emails with the exact same comment. Is there an easy method you are able to remove me from that service? Many thanks.

  50. you’re actually a just right webmaster. The web site loading velocity is amazing. It kind of feels that you are doing any distinctive trick. Furthermore, The contents are masterpiece. you have performed a fantastic job in this subject!