<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>noriok</author_name>
  <author_url>https://blog.hatena.ne.jp/noriok/</author_url>
  <blog_title>C#練習日記</blog_title>
  <blog_url>https://noriok.hatenadiary.jp/</blog_url>
  <categories>
  </categories>
  <description>d.hatena.ne.jp 上の記事で紹介されている「要素全体をメモリに保持せずに、ランダムな要素を選択する」アルゴリズムが面白いです。 C# で書いてみました。 public static class Extensions { // source が空だったり、配列やリストの場合の対応は後述 public static T RandomChoice&lt;T&gt;(this IEnumerable&lt;T&gt; source, Random random) { T selected = default(T); int n = 1; foreach (var e in source) { if (random…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fnoriok.hatenadiary.jp%2Fentry%2F2017%2F12%2F30%2F145107&quot; title=&quot;IEnumerable&amp;lt;T&amp;gt; のランダムな要素を選択する - C#練習日記&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2017-12-30 14:51:07</published>
  <title>IEnumerable&lt;T&gt; のランダムな要素を選択する</title>
  <type>rich</type>
  <url>https://noriok.hatenadiary.jp/entry/2017/12/30/145107</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
