`
cloud21
  • 浏览: 396335 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

AS3-Map

    博客分类:
  • Flex
 
阅读更多
Queue:

package test{
        public class Queue{
                private var arr:Array;
                private var pointer:uint;
                function Queue(){
                        this.arr = new Array();
                        this.pointer = 0;
                }
                public function element():*{
                        if(isEmpty()){
                                return null;
                        }else{
                                if(this.pointer < this.size()){
                                        return this.arr[this.pointer++];
                                }else{
                                        return null;
                                }
                        }
                }
                public function peek():*{
                        if(isEmpty()){
                                return null;
                        }else{
                                return this.arr[0];
                        }
                }
                public function poll():*{
                        this.pointer = 0;
                        if(isEmpty()){
                                return null;
                        }else{
                                return this.arr.shift();
                        }
                }
                public function add(object:*):Boolean{
                        this.pointer = 0;
                        if(this.contains(object)){
                                return false;
                        }else{
                                this.arr.push(object);
                                return true;
                        }
                }
                public function contains(object:*):Boolean{
                        for(var i:uint = 0;i<this.size();i++){
                                if(this.arr[i] == object){
                                        return true;
                                }
                        }
                        return false;
                }
                public function clear():void{
                        this.arr = new Array();
                        this.pointer = 0;
                }
                public function isEmpty():Boolean{
                        return this.size() == 0;
                }
                public function size():uint{
                        return this.arr.length;
                }
                public function toString():String{
                        return this.arr.toString();
                }
        }
}


MAP:

package test{
        
        import flash.utils.Dictionary;
        
        public class Map{
                
                private var _keys:Array = null;
                private var props:Dictionary = null;
                
                public function Map(){
                        this.clear();
                }
                public function clear():void{
                        this.props = new Dictionary();
                        this._keys = new Array();
                }
                public function containsKey(key:*):Boolean{
                        return this.props[key] != null;
                }
                public function containsValue(value:*):Boolean{
                        var result:Boolean = false;
                        var len:uint = this.size();
                        if(len > 0){
                                for(var i:uint = 0 ; i < len ; i++){
                                        if(this.props[this._keys[i]] == value) return true;
                                }
                        }
                }
                public function get(key:*):*{
                        return this.props[key];
                }
                public function put(key:*,value:*):*{
                        var result:* = null;
                        if(this.containsKey(key)){
                                result = this.get(key);
                                this.props[key] = value;
                        }else{
                                this.props[key] = value;
                                this._keys.push(key);
                        }
                        return result;
                }
                public function remove(key:*):*{
                        var result:* = null;
                        if(this.containsKey(key)){
                                delete this.props[key];
                                var index:int = this._keys.indexOf(key);
                                if(index > -1){
                                        this._keys.splice(index,1);
                                }
                        }
                        return result;
                }
                public function putAll(map:Map):void{
                        this.clear();
                        var len:uint = map.size();
                        if(len > 0){
                                var arr:Array = map.keys;
                                for(var i:uint=0;i<len;i++){
                                        this.put(arr[i],map.get(arr[i]));
                                }
                        }
                }
                public function size():uint{
                        return this._keys.length;
                }
                public function isEmpty():Boolean{
                        return this.size < 1;
                }
                public function values():Array{
                        var result:Array = new Array();
                        var len:uint = this.size();
                        if(len > 0){
                                for(var i:uint = 0;i<len;i++){
                                        result.push(this.props[this._keys[i]]);
                                }
                        }
                        return result;
                }
                public function keys():Array{
                        return this._keys;
                }
                
                public function toString():String{
                        var out:String = "";
                        for(var i:uint=0;i<this.size();i++){
                                out += this._keys[i] + ":"+this.get(this._keys[i]) + "\n";
                        }
                        return out;
                }
        }
}



Stack:

package test{
        public class Stack{
                private var arr:Array;
                private var pointer:uint;
                
                function Stack(){
                        this.arr = new Array();
                        this.pointer = 0;
                }
                
                public function element():*{
                        if(isEmpty()){
                                return null;
                        }else{
                                if(this.pointer < 0){
                                        return null;
                                }else{
                                        return this.arr[this.pointer--];
                                }
                        }
                }
                
                public function peek():*{
                        if(isEmpty()){
                                return null;
                        }else{
                                return this.arr[this.arr.length];
                        }
                }
                
                public function pop():*{
                        if(isEmpty()){
                                return null;
                        }else{
                                this.pointer = (this.size()>1)?this.size() - 2:0;
                                return this.arr.pop();
                        }
                }
                
                public function add(object:*):Boolean{
                        if(this.contains(object)){
                                this.pointer = this.size() - 2;
                                return false;
                        }else{
                                this.pointer = this.size() - 1;
                                this.arr.push(object);
                                return true;
                        }
                }
                public function contains(object:*):Boolean{
                        for(var i:uint = 0;i<this.size();i++){
                                if(this.arr[i] == object){
                                        return true;
                                }
                        }
                        return false;
                }
                
                public function clear():void{
                        this.arr = new Array();
                        this.pointer = 0;
                }
                
                public function isEmpty():Boolean{
                        return this.size() == 0;
                }
                
                public function size():uint{
                        return this.arr.length;
                }
                
                public function toString():String{
                        return this.arr.toString();
                }
        }
}

分享到:
评论

相关推荐

    配置route-map详解

    3. 路由过滤:Route-Map 可以用于路由过滤,根据不同的路由策略来过滤路由。 在本实验中,我们使用 Route-Map 来实现路由重发布,将 1.1.1.0 的路由重发布到 OSPF 中,类型为 OE1,metric=100;把 4.4.4.0 的路由重...

    RTAB-MAP开源视觉-激光-里程计SLAM代码

    1、RTAB-Map as an open-source lidar and visual simultaneous localization and mapping library for large-scale and long-term online operation-2018.pdf 2、RTABMAP_Appearance-Based_Loop_Closure_Detection_...

    BGP Route-Map Policy List Support

    ### BGP Route-Map Policy List Support详解 #### 概述 **BGP Route-Map Policy List Support**(边界网关协议路由映射策略列表支持)是Cisco系统在多个版本的Cisco IOS软件中引入的一项功能增强。该功能允许网络...

    route-maproute-map

    而set语句则用来修改这些匹配路由的属性,如设置metric、修改下一跳地址、改变AS路径、社区属性、本地优先级、权重或起源类型等。 配置route-map时,首先需要创建一个route-map实例,如`route-map test permit/deny...

    react-map-gl

    This library provides convenient wrappers around ... However, proceed with caution as calling the native APIs may break the connection between the React layer props and the underlying map state.

    emacs-bind-map:在多个位置绑定个人键盘映射

    3. 应用键绑定:使用`bind-keys-in-mode`在你需要的模式上应用这些绑定: ```elisp (bind-keys-in-mode my-bindings 'text-mode) (bind-keys-in-mode my-bindings 'prog-mode) ``` 这样,无论你在文本模式还是...

    react-map-interaction:将地图(如缩放和拖动)添加到任何元素

    安装npm install --save react-map-interaction用法基本的import { MapInteractionCSS } from 'react-map-interaction' ;// This component uses CSS to scale your content.// Just pass in content as children ...

    GO Map - 3D Map for AR Gaming 3.1.

    The demo scene is already set up and you can use it as a starting point. Buildings height and Roads width You can set the height and y position for every kind of polygon you want (buildings, water, ...

    浅谈as-path及基于as-path的路由过滤.docx

    * 对BGP路由其他属性的设置、修改,使用route-map、match as-path、set等命令。 四、AS路径access-list AS路径access-list是BGP路由策略实施中的一个重要工具,通过对AS路径的匹配,可以实现对BGP路由的过滤。AS...

    yahoo地图组件 yahoo-maps-as3-api-0.9.4-beta.zip

    《Yahoo地图组件:深入探索Yahoo Maps AS3 API 0.9.4 Beta》 Yahoo地图组件,全称为Yahoo Maps AS3 API,是一个专门用于在ActionScript 3(AS3)环境中集成和操作Yahoo地图的服务接口。这个组件允许开发者在Flex、...

    kafka-map:给编程插上翅膀,给kafka装上导航。Gitee镜像 https

    broker查看 —— Partitions as Leader、 Partitions as Follower consumer管理(查看、删除) 重置offset 消费消息 —— 支持String和json方式展示 截图 协议与条款 如您需要在企业网络中使用 kafka-map ,建议先...

    GoogleMap plot-google​-map 源码

    plot_google_map.m uses the Google Maps API to plot a map in the background of the current ... Additionally, it has the option to auto-refresh the map upon zooming in the figure, revealing more details as

    航空推进系统仿真C-MAPSS数据集,航空发动机剩余寿命预测的C-MAPSS数据集

    The data are provided as a zip-compressed text file with 26 columns of numbers, separated by spaces. Each row is a snapshot of data taken during a single operational cycle, each column is a different ...

    google map as3 源代码 源码

    在IT行业中,Google Map API是开发地图应用时广泛使用的工具,尤其在ActionScript 3(AS3)环境下,它为创建交互式地图提供了强大的支持。本文将深入探讨使用Google Map API进行AS3开发的相关知识点。 首先,让我们...

    POLYGON Dungeons Map - Low Poly 3D Art by Synty

    This Map pack expands out the Dungeons universe with new rooms and areas. ...https://assetstore.unity.com/packages/3d/environments/dungeons/polygon-dungeons-map-low-poly-3d-art-by-syn

    react-map-gl:围绕MapboxGL JS的React友好API包装器

    npm install --save react-map-gl例import * as React from 'react' ;import ReactMapGL from 'react-map-gl' ;function Map { const [ viewport , setViewport ] = React . useState ( { latitud

    MACOM MAPC-A3006-AB/AS GaN功率放大器

    ### MACOM MAPC-A3006-AB/AS GaN功率放大器 #### 产品概述 MACOM MAPC-A3006-AB/AS 是一款采用高效率、0.15微米氮化镓(GaN)在碳化硅(SiC)基底上制造工艺的未匹配封装晶体管。该晶体管支持高达18瓦的饱和功率,...

    ios-Map.zip

    本教程将通过"ios-Map.zip"中的资源,尤其是"LessonMapKit"文件,深入探讨如何使用Apple的MapKit框架进行地图的集成与操作。MapKit是iOS SDK提供的一种强大的工具,允许开发者在应用中嵌入交互式地图,实现定位、...

    Share-Map:一个用于共享和存储地图的iOS应用

    《Share-Map:基于Swift构建的iOS地图共享与存储应用详解》 在移动设备上,地图应用已经成为我们日常生活和工作中不可或缺的一部分。随着技术的发展,地图应用不再局限于简单的导航功能,而是朝着更个性化、社交化...

Global site tag (gtag.js) - Google Analytics