Opened 18 years ago

Closed 13 years ago

#315 closed Feature Requests (wontfix)

Implement operator[] for Tokenizer

Reported by: nobody Owned by: jsiek
Milestone: Component: tokenizer
Version: None Severity: Problem
Keywords: Cc:

Description (last modified by John Maddock)

I constantly find myself creating this structure:

tokenizer tok(str, sep);
vector<string> s;
for(tokenizer::iterator iter=tok.begin();
iter!=tok.end(); ++iter) {
  s.push_back(*iter);
}

Why not just:
tok[0];

to retrieve the first token?

(Darel Finkbeiner <darel.finkbeiner@sbcglobal.net>)

Change History (4)

comment:1 by John Maddock, 15 years ago

Description: modified (diff)
Owner: changed from John Maddock to jsiek
Severity: Problem
Status: assignednew

comment:2 by John Maddock, 15 years ago

Component: regextokenizer

comment:3 by Steven Watanabe, 13 years ago

The correct solution to this is

tokenizer tok(str, sep);
vector<string> s(tok.begin(), tok.end());

tokenizer cannot support random access efficiently because it is lazy and only has forward iterators.

comment:4 by Steven Watanabe, 13 years ago

Resolution: Nonewontfix
Status: newclosed
Note: See TracTickets for help on using tickets.