博文
数组dup的实现(2006-02-05 14:05:00)
摘要:Xref: digitalmars.com digitalmars.D:22525
Original Text:
Why there is no .dup property of AAs? And if .dup is used for array of, lets say, stucts that have another array as member is it duplicated too or if I modify it in the dup array the original will be modified too?
foo[bar] dup( foo[bar] arr )
{
foo[bar] copy;
foreach( bar key, foo val ; arr )
copy[key]=val;
return copy;
}
--------------------------------------------------------
泛型实现
template dup(Key, Value)
{
Value[Key] dup(Value[Key] aa)
{
Value[Key] copy;
foreach( Key key, Value val ; aa ) { copy[key]=val; }
return copy......
