package com.ta.common;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.AbstractList;
import java.util.Comparator;
import java.util.List;
import java.util.RandomAccess;
/**
* {@code Arrays} contains static methods which operate on arrays.
*
* @since 1.2
*/
public class Arrays
{
private static class ArrayList<E> extends AbstractList<E> implements
List<E>, Serializable, RandomAccess
{
private static final long serialVersionUID = -2764017481108945198L;
private final E[] a;
ArrayList(E[] storage)
{
if (storage == null)
{
throw new NullPointerException();
}
a = storage;
}
@Override
public boolean contains(Object object)
{
if (object != null)
{
for (E element : a)
{
if (object.equals(element))
{
return true;
}
}
} else
{
for (E element : a)
{
if (element == null)
{
return true;
}
}
}
return false;
}
@Override
public E get(int location)
{
try
{
return a[location];
} catch (ArrayIndexOutOfBoundsException e)
{
// throw
// java.util.ArrayList.throwIndexOutOfBoundsException(location,
// a.length);
throw e;
}
}
@Override
public int indexOf(Object object)
{
if (object != null)
{
for (int i = 0; i < a.length; i++)
{
if (object.equals(a[i]))
{
return i;
}
}
} else
{
for (int i = 0; i < a.length; i++)
{
if (a[i] == null)
{
return i;
}
}
}
return -1;
}
@Override
public int lastIndexOf(Object object)
{
if (object != null)
{
for (int i = a.length - 1; i >= 0; i--)
{
if (object.equals(a[i]))
{
return i;
}
}
} else
{
for (int i = a.length - 1; i >= 0; i--)
{
if (a[i] == null)
{
return i;
}
}
}
return -1;
}
@Override
public E set(int location, E object)
{
E result = a[location];
a[location] = object;
return result;
}
@Override
public int size()
{
return a.length;
}
@Override
public Object[] toArray()
{
return a.clone();
}
@SuppressWarnings("unchecked")
@Override
public <T> T[] toArray(T[] contents)
{
int size = size();
if (size > contents.length)
{
Class<?> ct = contents.getClass().getComponentType();
contents = (T[]) Array.newInstance(ct, size);
}
System.arraycopy(a, 0, contents, 0, size);
if (size < contents.length)
{
contents[size] = null;
}
return contents;
}
}
private Arrays()
{
/* empty */
}
/**
* Returns a {@code List} of the objects in the specified array. The size of
* the {@code List} cannot be modified, i.e. adding and removing are
* unsupported, but the elements can be set. Setting an element modifies the
* underlying array.
*
* @param array
* the array.
* @return a {@code List} of the elements of the specified array.
*/
public static <T> List<T> asList(T... array)
{
return new ArrayList<T>(array);
}
/**
* Performs a binary search for {@code value} in the ascending sorted array
* {@code array}. Searching in an unsorted array has an undefined result.
* It's also undefined which element is found if there are multiple
* occurrences of the same element.
*
* @param array
* the sorted array to search.
* @param value
* the element to find.
* @return the non-negative index of the element, or a negative index which
* is {@code -index - 1} where the element would be inserted.
*/
public static int binarySearch(byte[] array, byte value)
{
return binarySearch(array, 0, array.length, value);
}
/**
* Performs a binary search for {@code value} in the ascending sorted array
* {@code array}, in the range specified by fromIndex (inclusive) and
* toIndex (exclusive). Searching in an unsorted array has an undefined
* result. It's also undefined which element is found if there are multiple
* occurrences of the same element.
*
* @param array
* the sorted array to search.
* @param startIndex
* the inclusive start index.
* @param endIndex
* the exclusive start index.
* @param value
* the element to find.
* @return the non-negative index of the element, or a negative index which
* is {@code -index - 1} where the element would be inserted.
* @throws IllegalArgumentException
* if {@code startIndex > endIndex}
* @throws ArrayIndexOutOfBoundsException
* if {@code startIndex < 0 || endIndex > array.length}
* @since 1.6
*/
public static int binarySearch(byte[] array, int startIndex, int endIndex,
byte value)
{
checkBinarySearchBounds(startIndex, endIndex, array.length);
int lo = startIndex;
int hi = endIndex - 1;
while (lo <= hi)
{
int mid = (lo + hi) >>> 1;
byte midVal = array[mid];
if (midVal < value)
{
lo = mid + 1;
} else if (midVal > value)
{
hi = mid - 1;
} else
{
return mid; // value found
}
}
return ~lo; // value not present
}
/**
* Performs a binary search for {@code value} in the ascending sorted array
* {@code array}. Searching in an unsorted array has an undefined result.
* It's also undefined which element is found if there are multiple
* occurrences of the same element.
*
* @param array
* the sorted array to search.
* @param value
* the element to find.
* @return the non-negative index of the element, or a negative index which
* is {@code -index - 1} where the element would be inserted.
*/
public static int binarySearch(char[] array, char value)
{
return binarySearch(array, 0, array.length, value);
}
/**
* Performs a binary search for {@code value} in the ascending sorted array
* {@code array}, in the range specified by fromIndex (inclusive) and
* toIndex (exclusive). Searching in an unsorted array has an undefined
* result. It's also undefined which element is found if there are multiple
* occurrences of the same element.
*
* @param array
* the sorted array to search.
* @param startIndex
* the inclusive start index.
* @param endIndex
* the exclusive start index.
* @param value
* the element to find.
* @return the non-negative index of the element, or a negative index which
* is {@code -index - 1} where the element would be inserted.
* @throws IllegalArgumentException
* if {@code startIndex > endIndex}
* @throws ArrayIndexOutOfBoundsException
* if {@code startIndex < 0 || endIndex > array.length}
* @since 1.6
*/
public static int binarySearch(char[] array, int startIndex, int endIndex,
char value)
{
checkBinarySearchBounds(startIndex, endIndex, array.length);
int lo = startIndex;
int hi = endIndex - 1;
while (lo <= hi)
{
int mid = (lo + hi) >>> 1;
char midVal = array[mid];
if (midVal < value)
{
lo = mid + 1;
} else if (midVal > value)
{
hi = mid - 1;
} else
{
return mid; // value found
}
}
return ~lo; // value not present
}
/**
* Performs a binary search for {@code value} in the ascending sorted array
* {@code array}. Searching in an unsorted array has an undefined result.
* It's also undefined which element is found if there are multiple
* occurrences of the same element.
*
* @param array
* the sorted array to search.
* @param value
* the element to find.
* @return the non-negative index of the element, or a negative index which
* is {@code -index - 1} where the element would be inserted.
*/
public static int binarySearch(double[] array, double value)
{
return binarySearch(array, 0, array.length, value);
}
/**
* Performs a binary search for {@code value} in the ascending sorted array
* {@code array}, in the
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Android购物APP (1054个子文件)
gradlew.bat 2KB
.gitignore 8B
.gitignore 8B
build.gradle 929B
build.gradle 521B
build.gradle 506B
build.gradle 506B
build.gradle 506B
settings.gradle 71B
gradlew 5KB
pulltorefresh.iml 7KB
thinkinandroid.iml 7KB
xutils_library.iml 7KB
MIT-Afford.iml 941B
android-support-v4.jar 1.3MB
android-support-v7-appcompat.jar 583KB
glide-3.6.1.jar 464KB
fastjson-1.2.7.jar 407KB
alipaySdk-20160223.jar 318KB
locSDK_6.12.jar 247KB
sunjce_provider.jar 166KB
libammsdk.jar 146KB
mta-stats-sdk-2.0.4.jar 129KB
baidumapapi_base_v3_6_1.jar 96KB
greendao-1.3.7.jar 87KB
gradle-wrapper.jar 49KB
mta-mid-sdk-2.20.jar 41KB
baidumapapi_cloud_v3_6_1.jar 12KB
flymeapi.jar 9KB
Arrays.java 80KB
AtyOrdertDetail.java 48KB
PullToRefreshBase.java 45KB
AtySettlement.java 45KB
FragmentServerState.java 43KB
LruDiskCache.java 43KB
AdapterAllOrder.java 40KB
AdapterShoppingCart.java 39KB
AtyHome.java 37KB
DiskLruCache.java 33KB
AtySearch.java 33KB
WgtGridViewWithHeaderAndFooter.java 32KB
AtyAffordShop.java 32KB
AtyShoppingCart.java 28KB
WdtPagerTab.java 28KB
DbUtils.java 27KB
ArrayDeque.java 26KB
AsyncTask.java 25KB
AtyShoppingCart_bak.java 25KB
WheelView.java 24KB
AdapterFrgOrderNotake.java 24KB
AtyMyAddressUpdata.java 23KB
Deque.java 23KB
UtilJSON.java 22KB
AtyAffordShopDetail.java 22KB
AtyMyCollect.java 21KB
AtyServerSettlement.java 21KB
FragmentServerDetail.java 20KB
TAStringUtils.java 19KB
WdtPagerTabServerTime.java 19KB
AtyMyAddressNew.java 19KB
AtyServerHouseSettlement.java 19KB
AtyRegister.java 18KB
AffConstans.java 18KB
AtyMy.java 18KB
WdtPagerSlidingTabStrip.java 17KB
BitmapCache.java 17KB
AtyLogin.java 17KB
BitmapUtils.java 17KB
PriorityObjectBlockingQueue.java 17KB
WgtHeaderGridView.java 17KB
URLEncodedUtils.java 16KB
BusinessUser.java 16KB
AtySettlementOrder.java 16KB
AtyLocation.java 15KB
AtyWelCome.java 15KB
AdapterFrgServerOrderWaitSer.java 15KB
PullToRefreshAdapterViewBase.java 14KB
AdapterFrgOrderNopay.java 14KB
BusinessServer.java 14KB
BitmapGlobalConfig.java 14KB
HttpUtils.java 14KB
PriorityAsyncTask.java 13KB
WdtBadgeView.java 13KB
TAFileCache.java 13KB
HttpHandler.java 13KB
AdapterCollect.java 12KB
AtyRegisterVerify.java 12KB
AdapterFrgOrderEvaluate.java 12KB
WidgetMenuLayout.java 12KB
ExpandTabView.java 12KB
FragmentShopDetailPager.java 12KB
FragmentServerDetailPager.java 12KB
UtilNumber.java 12KB
LoadingLayout.java 12KB
AdapterFrgServerOrderNopay.java 12KB
AdapterFrgServerOrderComplete.java 12KB
AtyHomeSpecialList.java 11KB
UtilPreferences.java 11KB
AdapterAffordShop.java 11KB
BusinessBase.java 11KB
共 1054 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
资源评论
- zzia722019-05-29还可以用,借鉴!
- qq_422171402019-05-10内容还不错X
qq_41935839
- 粉丝: 10
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 2025计量基础知识考试题库及答案.doc
- 2025金属冶炼(炼钢)安全员考试题库(含答案).pptx
- 2025健康管理师三级专业能力考核试卷及答案.doc
- 2025交管12123驾驶证学法减分题库附含答案.doc
- 建筑工程员工工资表.xls
- 工程部薪酬2018年6月.doc
- 工程施工操作员薪酬管理制度.doc
- 2025教育心理学与德育工作基础知识点大全.doc
- 2025教育心理学与德育工作基础知识点整理总复习资料.doc
- 2025基本公共卫生知识考试题及答案.docx
- 2025基本公共卫生知识题库及答案.docx
- 2025基础知识与规范要求技能大赛题库及答案.docx
- 2025脊柱术后脑脊液漏应急预案考试试题(含答案).docx
- 2025计量基础知识题库及答案.docx
- 2025计算机二级考试全真试题库及答案(通用版).docx
- 2025计算机基础理论信息安全基本知识试题及答案.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功