[AS3]as3下数组重复元素源代码示例
var arr:Array=new Array();
arr = ["afuhan","jianpuzhai","saipulusi","yameiniya","alianqiu","kataer","shate","yemen",
"asaibaijiang","keweite","sililanka","yilake","bajisitan","laowo","taiguo","yilang","zhongguo"];
var len:int = arr.length;
trace(len);
getRepeat(arr)
function getRepeat(a:Array):Array
{
var m:Number = 0;
var repeat = [];//记录重复的元素
var repeatNum = [];//记录重复次数
var noRepeat = [];//记录没有重复的元素
var n = a.length;
for (var i=0; i m = 1;
if (a[i] == -1) {
continue;
}
for (var j=i+1; j if (a[i] == a[j]) {
m++;
a[j] = -1;
}
}
if (m > 1) {
trace(“a[i]=” + a[i]);
trace(“m=”+m);
repeat.push(a[i]);
repeatNum.push(m);
} else if (m==1) {
noRepeat.push(a[i]);
}
}
return [repeat,repeatNum,noRepeat] ;
//返回 重复的元素,重复次数,没有重复的元素
}
热门文章推荐
- 纯HLS(m3u8)跨平台技术(HLSPlayer,m3u8Player跨平台多终端)
- DiscuzX3.2酷播视频插件(dz论坛自定义视频插件带广告
- [微信视频]实现网站中的视频在微信平台上正常播放(超多组图)
- [rtsp]海康威视监控摄像头实现web端无插件监控实拍效果
- 很酷,酷播wordpress视频插件(支持PC/安卓/苹果跨平台播放)
- [组图]微信视频技术:支持微信视频直播和视频点播
- [AS3]as3.0的rtmp流媒体播放器写法源代码示例
- 一步一步教你制作FLV网页视频播放器