private class ArrayTool<T>
{
/// <summary>查询值在数组中的下标</summary>
/// <param name="array">数组</param>
/// <param name="param">查询的参数</param>
/// <returns>下标</returns>
public static int ArrayQueryIndex(T[] array, T param)
{
for (int i = ; i < array.Length; i++)
if (array[i].Equals(param)) return i;
return ;
}
/// <summary>根据下标拆分出新数组</summary>
/// <param name="array">原数组</param>
/// <param name="EndIndex">结束下标</param>
/// <param name="StartIndex">开始下标</param>
/// <returns>新数组</returns>
public static T[] NewArrayByIndex(T[] array, int EndIndex, int StartIndex)
{
T[] result = new T[EndIndex - StartIndex + ];
for (int i = ; i <= EndIndex - StartIndex; i++) result[i] = array[i + StartIndex];
return result;
}
}

数组根据index拆分和查询下标的更多相关文章

  1. 将两个数组相同index的value合并成一个新的value组成一个新的数组

    将两个数组相同index的value合并成一个新的value组成一个新的数组 前提: 这两个数组的长度相同 生成后的新数组长度也相同 返回值都是对象 把rows对象的key和value弄成两个数组, ...

  2. ElasticSearh更新nested字段(Array数组)。怎么根据查询条件(query)复制一个(index)到新的Index how to update by query a nested fields data for elasticsearch

    GET usernested/_search { "query": { "nested": { "path": "tags&quo ...

  3. 知道一个数组某个index对应的值 不知道下标的情况下删除该值

    for (index,item) in Arr.enumerated() { if item == item { Arr.remove(at: index) } } 更好的方法是用数组的filter尾 ...

  4. MVVM架构~knockoutjs系列之数组的$index和$data

    返回目录 已经写了很多knockoutjs的文章了,今天在review代码时,忽然看到一个问题,在knockout环境下,如何遍历一个简单的数组?对于遍历对象组件的数组来说,很容易,直接foreach ...

  5. 索引 使用use index优化sql查询

    好博客:MySQL http://webnoties.blog.163.com/blog/#m=0&t=1&c=fks_08407108108708107008508508609508 ...

  6. Javascript实例:求数组中最大、最小值及下标

    题目:定义一个数组,并给出7个整数,求该数组中的最大值,及最大值下标,最小值及最小值下标.<script type="text/javascript">//定义一个数组 ...

  7. 数组Magic Index

    Question A magic index in an array A[1...n-1] is defined to be an index such that A[i] = i. Given a ...

  8. POJ 2155 Matrix 【二维树状数组】(二维单点查询经典题)

    <题目链接> 题目大意: 给出一个初始值全为0的矩阵,对其进行两个操作. 1.给出一个子矩阵的左上角和右上角坐标,这两个坐标所代表的矩阵内0变成1,1变成0. 2.查询某个坐标的点的值. ...

  9. javascript数组中数字和非数字下标的区别(转)

    http://blog.csdn.net/qq_27461663/article/details/52014911 考完试后闲来无事,想起好多天没写js了,于是打算实践一下最近看到的一些好玩的点子.结 ...

随机推荐

  1. navicat批量导入数据

    1.excel表导入数据 根据数据表添加excel表内容 开始导入数据

  2. 「SCOI2016」美味

    「SCOI2016」美味 题目描述 一家餐厅有 \(n\) 道菜,编号 \(1 \ldots n\) ,大家对第 \(i\) 道菜的评价值为 \(a_i \:( 1 \leq i \leq n )\) ...

  3. 升级到php7和安装拓展(mac centos)

    Mac升级到php7 使用homebrew安装php7 brew update #更新源 brew search php #查找源中的php,发现有php7.1版本,安装最新的php7.1 brew ...

  4. bzoj 1269 bzoj 1507 Splay处理文本信息

    bzoj 1269 题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1269 大致思路: 用splay维护整个文本信息,splay树的中序遍历即为 ...

  5. [转]Intent和PendingIntent的区别

    intent英文意思是意图,pending表示即将发生或来临的事情. PendingIntent这个类用于处理即将发生的事情.比如在通知Notification中用于跳转页面,但不是马上跳转. Int ...

  6. jquery datatables使用

    引入相应css 和js <link href="http://cdn.datatables.net/1.10.5/css/jquery.dataTables.css" rel ...

  7. system.ComponentModel.Win32Exception (0x80004005): 目录名无效。 解决方法

    有时候我们需要在程序中调用 cmd.exe  执行一些命令 比如 我们会在程序写到 /// <summary> /// 执行Cmd命令 /// </summary> /// & ...

  8. What is the Linux High Availabi

    What is the Linux High Availabi    简介:     高可用性群集的出现是为了使群集的整体服务尽可能可用,以便考虑计算硬件和软件的易错性.如果高可用性群集中的主节点发生 ...

  9. SpringMVC访问静态页面

    Spring MVC显示静态页面 在前面搭建spring MVC环境时,我们设置了spring-mvc配置,通过tomcat来访问了index.jsp 页面,但是当我将页面换成.thml的静态面之后就 ...

  10. python核心模块之pickle和cPickle解说

    pickle模块使用的数据格式是python专用的,而且不同版本号不向后兼容,同一时候也不能被其它语言说识别.要和其它语言交互,能够使用内置的json包使用pickle模块你能够把Python对象直接 ...