-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update work experience and sort algorithms
- Loading branch information
zhaofengyi
committed
Sep 3, 2019
1 parent
7498505
commit 35102ac
Showing
6 changed files
with
446 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
[TOC] | ||
|
||
# Ten classic sort algorithms | ||
|
||
## Bubble sort | ||
|
||
```java | ||
import java.util.Arrays; | ||
public class BubbleSort { | ||
public int[] sort(int[] srcArr) { | ||
int[] arr = Arrays.copyOf(srcArr, srcArr.length); | ||
boolean hasChanged; | ||
for (int i = arr.length - 1; i > 0; i --) { | ||
hasChanged = false; | ||
for (int j = 0; j < i; j ++) { | ||
if (arr[j] > arr[j + 1]) { | ||
int tmp = arr[j]; | ||
arr[j] = arr[j + 1]; | ||
arr[j + 1] = tmp; | ||
hasChanged = true; | ||
} | ||
} | ||
if (!hasChanged) { | ||
break; | ||
} | ||
} | ||
return arr; | ||
} | ||
} | ||
``` | ||
|
||
* **重点** | ||
|
||
import java.util.Arrays; | ||
public class BubbleSort { | ||
public int[] sort(int[] srcArr) { | ||
int[] arr = Arrays.copyOf(srcArr, srcArr.length); | ||
boolean hasChanged; | ||
|
||
>#### for (int i = arr.length - 1; i > 0; i --) { | ||
hasChanged = false; | ||
|
||
> #### for (int j = 0; j < i; j ++) { | ||
if (arr[j] > arr[j + 1]) { | ||
int tmp = arr[j]; | ||
arr[j] = arr[j + 1]; | ||
arr[j + 1] = tmp; | ||
hasChanged = true; | ||
} | ||
} | ||
if (!hasChanged) { | ||
break; | ||
} | ||
} | ||
return arr; | ||
} | ||
} | ||
|
||
## Selection sort | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
## Insert sort | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
## Shell sort | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
## Merge sort | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
## Quick sort | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
## Heap sort | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
## Counting sort | ||
|
||
|
||
|
||
|
||
|
||
## Bucket sort | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
## Radix sort | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
|
||
|
||
|
||
## 问题: | ||
|
||
MoosLauncher.apk是在android studio中开发的,放到aosp 7.1.2以及8.1.0上都可以编过: | ||
|
||
```makefile | ||
file Android.mk: | ||
LOCAL_PATH := $(call my-dir) | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := MoosLauncher | ||
LOCAL_MODULE_TAGS := optional | ||
LOCAL_DEX_PREOPT:= false | ||
LOCAL_SRC_FILES := launcher3/build/MoosLauncher.apk | ||
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) | ||
LOCAL_CERTIFICATE := PRESIGNED | ||
LOCAL_MODULE_CLASS := APPS | ||
include $(BUILD_PREBUILT) | ||
``` | ||
|
||
但是放到aosp 4.4.4上出现了报错,out/host/linux-x86/bin/zipalign无法对此apk进行优化: | ||
|
||
target Prebuilt APK: MoosLauncher (out/target/product/rk312x/obj/APPS/MoosLauncher_intermediates/MoosLauncher.apk) | ||
**out/host/linux-x86/bin/zipalign** -f 4 packages/apps/MoosLauncher/launcher3/build/MoosLauncher.apk out/target/product/rk312x/obj/APPS/MoosLauncher_intermediates/MoosLauncher.apk | ||
build/core/prebuilt.mk:151: recipe for target 'out/target/product/rk312x/obj/APPS/MoosLauncher_intermediates/MoosLauncher.apk' failed | ||
make: * * * [out/target/product/rk312x/obj/APPS/MoosLauncher_intermediates/MoosLauncher.apk] Error 1 | ||
make: * * * Deleting file 'out/target/product/rk312x/obj/APPS/MoosLauncher_intermediates/MoosLauncher.apk' | ||
|
||
// todo zipalign 作用:优化apk res文件,对齐,运行速度加快 | ||
|
||
## 解决办法: | ||
|
||
* 安卓4.4.4版本上弃用Android.mk,改用PRODUCT_COPY_FILES += packages/apps/MoosLauncher/launcher3/build/MoosLauncher.apk:system/priv-app/MoosLauncher.apk | ||
|
||
* 修改build/core/Makefile中的error为warning: | ||
|
||
```makefile | ||
define check-product-copy-files | ||
$(if $(filter %.apk, $(1)),$(error \ | ||
Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!)) | ||
endef | ||
``` | ||
|
||
改成 | ||
|
||
```makefile | ||
define check-product-copy-files | ||
$(if $(filter %.apk, $(1)),$(warning \ | ||
Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!)) | ||
endef | ||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Not accessible for namespace | ||
|
||
参考https://www.jianshu.com/p/4be3d1dafbec | ||
|
||
### 问题: | ||
|
||
做图像对比需要在/system/lib下加入一个新的库libopencv_java4.so | ||
|
||
在安卓低版本上没问题,在高版本上报了个错误: | ||
|
||
System.err: java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/lib/libopencv_java4.so" | ||
needed or dlopened by "/system/lib/libnativeloader.so" is not accessible for the namespace "classloader-namespace" | ||
|
||
搜索了一下,原来是普通应用不能直接引用系统的一些so库了,只能直接引用public.libraries.txt文件中过滤的so库。这个网址有介绍怎么处理。 | ||
[https://source.android.com/devices/tech/config/namespaces_libraries](https://link.jianshu.com?t=https://source.android.com/devices/tech/config/namespaces_libraries) | ||
|
||
### 解决: | ||
|
||
```txt | ||
diff --git a/rootdir/etc/public.libraries.android.txt b/rootdir/etc/public.libraries.android.txt | ||
index 5482085..d65453d 100644 | ||
--- a/rootdir/etc/public.libraries.android.txt | ||
+++ b/rootdir/etc/public.libraries.android.txt | ||
@@ -23,3 +23,4 @@ libsync.so | ||
libvulkan.so | ||
libwebviewchromium_plat_support.so | ||
libz.so | ||
+libopencv_java4.so | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[TOC] | ||
|
||
# 安卓适配 | ||
|
||
## 屏幕适配: | ||
|
||
用ScreenMatch根据屏幕尺寸生成不同的dimen | ||
|
||
https://www.jianshu.com/p/1302ad5a4b04 | ||
|
||
https://github.com/wildma/ScreenAdaptation/blob/master/app/src/main/res/values/dimens.xml | ||
|
Oops, something went wrong.