dcollections how to LinkList // port c# code
Byron Heads
wyverex.cypher at gmail.com
Tue Jun 29 12:49:18 PDT 2010
On Tue, 29 Jun 2010 15:27:41 -0400, bearophile wrote:
> In D use dynamic arrays unless you really need to remove or add a lot of
> items from the start or middle of the sequence. On modern CPUs linked
> lists are usually the wrong data structure to use.
>
> Bye,
> bearophile
D's dynamic arrays are great! Also you should create a constructor for a
common build operation.
--------------------------------------------
import std.stdio;
class Server
{
string name;
string ip;
this( string _name, string _ip ) { name = _name; ip = _ip; }
string toString() { return name ~ " - " ~ ip; }
}
void main()
{
Server[] serverList = [ new Server( "a", "164.76.0.1" ),
new Server( "b", "164.76.0.2" ) ];
foreach( server; serverList ) {
writeln( server );
}
}
-----------------------------------------
a - 164.76.0.1
b - 164.76.0.2
-B
More information about the Digitalmars-d-learn
mailing list