codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
import std.string; import std.stdio; class Map(NameT, ValueT) { private: NameT[ValueT] m_realmap; public: this() { } ref Map insert(ref const(NameT) name, ref const(ValueT) value) { m_realmap[name] = value; return this; } int size() { return m_realmap.length; } ref ValueT opIndex(ref const(NameT) name) { return m_realmap[name]; } ref NameT opIndex(int idx) { return m_realmap.keys[idx]; } ref Map opIndexAssign(ref const(ValueT) value, ref const(NameT) name) { this.insert(name, value); return this; } } int main() { Map!(string, string) names = new Map!(string, string); names["hello"] = "world"; names["foo"] = "bar"; for(int i=0; i<names.size(); i++) { writefln("%s => %s", names[i], names[names[i]]); } return 0; }
Private
[
?
]
Run code
Submit