ready
// 定义一个动物类
function Animal (name) {
// 属性
this.name = name || 'Animal';
// 实例方法
this.sleep = function(){
console.log(this.name + '正在睡觉!');
}
}
// 原型方法
Animal.prototype.eat = function(food) {
console.log(this.name + '正在吃:' + food);
};
function Cat(name){
Animal.call(this);
this.name = name || 'Tom';
}
(function(){
// 创建一个没有实例方法的类
var Super = function(){};
Super.prototype = Animal.prototype;
//将实例作为子类的原型
Cat.prototype = new Super();
})();
// Test Code
var cat = new Cat();
console.log(cat.name);
console.log(cat.sleep());
console.log(cat instanceof Animal); // true
console.log(cat instanceof Cat); //true
public class MyStack<T> : IEnumerable<T>, IDisposable
{
private int _top = ;
private int _size = ;
private T[] _stack = null; public int Top
{
get
{
return _top;
}
} public int Size
{
get
{
return _size;
}
} public int Length
{
get
{
return _top;
}
} public T this[int index]
{
get
{
return _stack[index];
}
} public MyStack(int size)
{
_size = size;
_top = ;
_stack = new T[size];
} public bool IsEmpty()
{
return _top == ;
} public bool IsFull()
{
return _top == _size;
} public void Clear()
{
_top = ;
} /// <summary>
/// 入栈
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
public bool Push(T node)
{
if (!IsFull())
{
_stack[_top] = node;
_top++;
return true;
}
return false;
} /// <summary>
/// 出栈
/// </summary>
/// <returns></returns>
public T Pop()
{
T node = default(T);
if (!IsEmpty())
{
_top--;
node = _stack[_top];
}
return node;
} public void Traverse()
{
for (int i = ; i < _top; i++)
{
Console.WriteLine(_stack[i]);
}
} public IEnumerator<T> GetEnumerator()
{
for (int i = ; i < _stack.Length; i++)
{
if (_stack[i] != null)
{
yield return _stack[i];
}
}
} IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
} public void Dispose()
{
_stack = null;
}
}
ready的更多相关文章
- jquery中的$(document).ready(function() {});
当文档载入时执行function函数里的代码, 这部分代码主要声明,页面加载后 "监听事件" 的方法.例如: $(document).ready( $("a") ...
- 谈谈document.ready和window.onload的区别
在Jquery里面,我们可以看到两种写法:$(function(){}) 和$(document).ready(function(){}) 这两个方法的效果都是一样的,都是在dom文档树加载完之后执行 ...
- $(document).ready() 与window.onload的区别
1.执行时间 window.onload必须等到页面内包括图片的所有元素加载完毕后才能执行. $(document).ready()是DOM结构绘制完毕后就执行,不必等到加载完毕. 2.编写个数不同 ...
- DOM加载过程中ready和load的区别
在浏览器地址栏输入URL地址,浏览器开始加载页面时,有以下几个过程 1.浏览器开始解析HTML文档 2. 浏览器遇到HTML文档中的<script>元素以及CSS样式文件,并且没有asyn ...
- jq方法中 $(window).load() 与 $(document).ready() 的区别
通过自学进入了前端的行列,只知道在js中,一开头就写一个: window.onload = function(){ //doing sth} 然后所有的乱七八糟的代码全塞里面,大概知道window.o ...
- jQuery $(document).ready() 与window.onload的区别
ps:jQuery中$(document).ready()的作用类似于传统JavaScript中的window.onload方法,虽然具有类似的效果,但是它们在触发操作的时间上存在着微妙的差异. 在j ...
- $(document).ready,$(window).load,window.onload区别和联系
$(document).ready是在dom结构加载完毕就执行. $(window).load 等价于window.onload,必须等到页面内包括图片的所有元素加载完毕后才能执行. $(docume ...
- window.onload和$(document).ready(function(){})的区别
前段时间在面试之前查找并整理了一下window.onload和$(document).ready(function(){})区别,今天有时间更到我的博客上,由于本人资历尚浅,如有不对的地方,还请指正. ...
- window.onload与$(document).ready()的区别
对于很多初学者来说,window.onload出现在代码中的频率非常高,这似乎变成了一种习惯,可是并不知道具体为什么要加这句代码,可以做几个试验对比: 实验一: <script> docu ...
- jQuery之ready源码分析
只要使用过jQuery的,想必对ready都不陌生,$(function(){})和$(document).ready(function(){})的使用更是习以为常. 要说到window.onload ...
随机推荐
- flask基础三
一.路由和视图(基础二上补充) (1)有参装饰器 路由采用的是有参装饰器实现的 @app.route("/index",methods=["GET"," ...
- LeetCode 217 Contains Duplicate 解题报告
题目要求 Given an array of integers, find if the array contains any duplicates. Your function should ret ...
- linux和shell的学习记录
1.16条常用的命令 .文件的权限修改:(把文件1.txt的归属改为mysql的,然后ll查看) chown mysql:mysql .txt .增加当前用户的x权限,然后ll查看: chomd u+ ...
- 解决python tkinter 与 sleep 延迟问题
多线程(threading——join) join ()方法:主线程A中,创建了子线程B,并且在主线程A中调用了B.join(),那么,主线程A会在调用的地方等待,直到子线程B完成操作后, 才可以接着 ...
- 【Bad Practice】12306 query
- 【LeetCode每天一题】Minimum Path Sum(最短路径和)
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...
- c++简单程序设计 实验一
实验内容: 2-28 实现一个简单的菜单程序,运行时显示“Menu:A(dd) D(elete) S(ort) Q(uit),Selete one:”提示用户输入.A表示增加,D表示删除, S表示排序 ...
- 关于Linux目录结构的理解
dUI与刚接触Linux的学习者来说,那么多的根下目录足够让我们头疼不已,如下图: 那么对于初学者来说,我们首要了解的是哪些目录呢? 就是这个标黄绿色的tmp目录,此目录是一个存放临时文件夹的目录( ...
- 微信小程序之回调函数
在微信小程序中众所周知在js里面得方法都是异步执行,我最近再做项目得时候也遇到了这个问题,再方法里面调用另一个方法里面的接口数据,第一次是调取不到的, 因为两个方法是同时开始执行得,所以怎么都取不到值 ...
- 005-CSS让页脚始终在底部不论页面内容多少
让页脚始终在页面底部,不论页面内容是多或者少页脚始终在页面底部. 方案一: <!DOCTYPE html> <html> <head> <meta chars ...