invalidate方法源码分析 在之前分析View的绘制流程中,最后都有调用一个叫invalidate的方法,这个方法是啥玩意?我们来看一下View类中invalidate系列方法的源码(ViewGroup没有重写这些方法),如下: /** * Mark the area defined by dirty as needing to be drawn. dirty代表需要重新绘制的脏的区域 * , 0, mRight - mLeft, mBottom - mTop, invalidateC…
Linq分组操作之GroupBy,GroupJoin扩展方法源码分析 一. GroupBy 解释: 根据指定的键选择器函数对序列中的元素进行分组,并且从每个组及其键中创建结果值. 查询表达式: var list = new List<object>() { 20, 30, 24 };查询表达式: var query = from n in list group n by n into grp select new { MyKey = grp.Key, MyValue = grp.Count()…
v8--sort方法源码中对于长度较短的数组使用的是插入排序法. 部分源码: function InsertionSort(a, from, to) { for (var i = from + 1; i < to; i++) { var element = a[i]; // Pre-convert the element to a string for comparison if we know // it will happen on each compare anyway. var key…
// 数组中的reduce方法源码复写 //先说明一下reduce原理:总的一句,reduce方法主要是把数组遍历, //然后把数组的每个元素传入回调函数中,回调函数怎么处理,就会的到什么样的效果 Array.prototype._reduce=function(fn,initVal){ let pre=initVal;//对初始值进行赋值 let i=0;//数组的出事索引值 if(!pre){//判断是否拥有初始值,如果有传初始值,下面遍历会从零开始,否则,遍历从1开始,下面遍历的第一个的p…