続・C++でStringTokenizerっぽいことをやってみる

| | TrackBacks (0)

 前回の記事haveの指摘に従い、参照渡しをやめてヴェクタを返す関数にしてみた。

std::vector<string> 
slice(const std::string source, const std::string dem)
{
  std::string::size_type i1 = 0;
  std::string::size_type i2 = source.find(dem);
  std::vector<string> retval;

  if(std::string::npos == i2)
    return retval;

  std::string s = source + dem;

  do{
    retval.push_back(s.substr(i1, i2-i1));
    i1 = i2+1;
  }while(std::string::npos != (i2 = s.find(dem, i1)));

  return retval;
}

 ちょっと効率は落ちたが、Atomicになったので前回のコードにくらべ、マルチスレッドプログラミングで安全に使えるようになった。

Thanks! nice comment > Have

Categories

0 TrackBacks

Listed below are links to blogs that reference this entry: 続・C++でStringTokenizerっぽいことをやってみる.

TrackBack URL for this entry: http://www.argv.org/~chome/blog/mt-tb.cgi/77

About Me

中尾 圭佐(chomy)
千葉県船橋市在住のモノクロ写真に目覚めた研究者。
Twitter ID: jm6xxu
Skype: chomy

My Tweets

jm6xxu: かなりバッファリングしているのか、50秒ほど遅れて聞こえる。

jm6xxu: なんか、今文化放送でやってる番組、なんかエロいw

jm6xxu: よし、iPhoneでradikoが聴けた。もう寝る。

jm6xxu: rtmpdump -> ffmpg -> ices2 -> icecast2 でradikoをre-streamingすることに成功。IceS2を使っているのでoggなのだが、IceS0でmp3にすればiPhoneでも聴けるようになるはず。

jm6xxu: 仕事終了。これから帰る。明日はdebian勉強会と友人たちと会食。明後日の午後には伊豆大島だ。まだ全然準備ができてない。フィルムすら用意してないし、カメラの電池切れそうだし....明日忘れずに購入しなければ。

About this Entry

This page contains a single entry by chomy published on June 14, 2009 3:16 AM.

C++でStringTokenizerっぽいことをやってみる was the previous entry in this blog.

MacBookPro 購入 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.261