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
int binary_search_first_position(int *A, int n, int target) | |
{ | |
int low = -1, high = n; | |
assert(A != NULL && n >= 0); | |
while (low + 1 < high) | |
{ | |
int mid = (low + high) >> 1; | |
if (A[mid] < target) | |
low = mid; | |
else |
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
--[[ | |
Date: 2014-8-1 | |
Licence: MIT | |
Author: <begeekmyfriend@gmail.com> | |
<xfguo@credosemi.com> | |
]] | |
--[[ | |
module_relation table | |
key -- module name |
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
#define MSG_CODEC(ACTION) \ | |
ACTION( UNKNOWN, ""/* unknown */ ) \ | |
ACTION( REQ_GET, "get " ) \ | |
ACTION( REQ_GETS, "gets " ) \ | |
ACTION( REQ_DELETE, "delete " ) \ | |
ACTION( REQ_CAS, "cas " ) \ | |
ACTION( REQ_SET, "set " ) \ | |
ACTION( REQ_ADD, "add " ) \ | |
ACTION( REQ_REPLACE, "replace " ) \ | |
ACTION( REQ_APPEND, "append " ) \ |
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
/* | |
* This file is part of SmartSNMP | |
* Copyright (C) 2014, Credo Semiconductor Inc. | |
* | |
* This program is free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation; either version 2 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, |
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
HOST=linux-x86_64 | |
NDK=/opt/android-ndk-r8e | |
PLATFORM=$NDK/platforms/android-14/arch-arm | |
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/$HOST | |
CPU=armv7-a | |
PREFIX=$(pwd)/../build_android/$CPU |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
/* https://zhuanlan.zhihu.com/p/345364527 */ | |
static inline int max(int a, int b) | |
{ | |
return a > b ? a : b; | |
} |
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
#include <stdio.h> | |
#include <stdlib.h> | |
static void show(int *nums, int lo, int hi) | |
{ | |
int i; | |
for (i = lo; i <= hi; i++) { | |
printf("%d ", nums[i]); | |
} |
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
#include <stdio.h> | |
#include <stdlib.h> | |
static inline void swap(int *a, int *b) | |
{ | |
int tmp = *a; | |
*a = *b; | |
*b = tmp; | |
} |
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
void sort(int *nums, int size) | |
{ | |
int i, j; | |
for (i = 1; i < size; i++) { | |
int tmp = nums[i]; | |
for (j = i; j > 0 && tmp < nums[j - 1]; j--) { | |
nums[j] = nums[j - 1]; | |
} | |
nums[j] = tmp; | |
} |
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
void sort(int *nums, int size) | |
{ | |
int i, flag = size; | |
while (flag > 0) { | |
int len = flag; | |
flag = 0; | |
for (i = 1; i < len; i++) { | |
if (nums[i - 1] > nums[i]) { | |
int tmp = nums[i - 1]; | |
nums[i - 1] = nums[i]; |
OlderNewer