标签:sde for eve containe his ber else foreach lse
let $cell : BeeCreateVo = null;
let $find : BeeCreateVo = null;
this._hash_map.forEach( ( $arr : Array<BeeCreateVo> , $key : TY_SoldierContainer , $map : any ) : void => {
if( $arr && $arr.length > 0 ){
for( let $i : number = 0 , $j : number = $arr.length ; $i < $j ; $i ++ ){
$cell = $arr[$i];
if( $cell.soldier_id == $id ){
$find = $cell;
break;
}
}
}
} );
PS :
$arr : 既是Map的value
$key : 既是Map的key
注意 forEach里面不能return , 所以 :
public getSoliderById( $id : number , $isDeepCopy : boolean = false ) : BeeCreateVo{
let $cell : BeeCreateVo = null;
let $find : BeeCreateVo = null;
this._hash_map.forEach( ( $arr : Array<BeeCreateVo> , $key : TY_SoldierContainer , $map : any ) : void => {
if( $arr && $arr.length > 0 ){
for( let $i : number = 0 , $j : number = $arr.length ; $i < $j ; $i ++ ){
$cell = $arr[$i];
if( $cell.soldier_id == $id ){
$find = $cell;
break;
}
}
}
} );
if( $find ){
if( !$isDeepCopy ){
return $find;
}else{
return {
id : $find.id,
soldier_id : $find.soldier_id,
soldier_num : $find.soldier_num,
soldier_used_num : $find.soldier_used_num,
technology_level : $find.technology_level,
time_out : $find.time_out,
status_code : $find.time_out
}
}
}
return null;
}
标签:sde for eve containe his ber else foreach lse
原文地址:https://blog.51cto.com/aonaufly/2387505