ARST第三周打卡
Algorithm : 做一个 leetcode 的算法题
//二位数组查找 题目描述
//在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。
//请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。
bool FindNum(int target, vector<vector<int> > vect)
{
int iRow = vect.size();
int iCol = vect[0].size(); //从左上角开始遍历
int i = 0, j = iCol - 1;
while (i <= iRow - 1 && j >= 0) //保证数组不能越界
{
if (vect[i][j] > target)
{
j--;
}
else if (vect[i][j] < target)
{
i++;
}
else
{
return true;
}
} return false;
}
Review : 阅读并点评一篇英文技术文章
原文地址:http://download.redis.io/redis-stable/redis.conf
################################ SNAPSHOTTING ################################
#
# Save the DB on disk:
#
# save <seconds> <changes>
#
# Will save the DB if both the given number of seconds and the given
# number of write operations against the DB occurred.
根据给定的每秒多少写操作保存DB;
#
# In the example below the behaviour will be to save:
# after 900 sec (15 min) if at least 1 key changed
# after 300 sec (5 min) if at least 10 keys changed
# after 60 sec if at least 10000 keys changed
#
# Note: you can disable saving completely by commenting out all "save" lines.
#
# It is also possible to remove all the previously configured save
# points by adding a save directive with a single empty string argument
# like in the following example:
#
# save ""
save 900 1
save 300 10
save 60 10000
保存DB到磁盘:
# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# This will make the user aware (in a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.
默认情况下:如果开启了RDB快照(至少一个保存点)并且最后一个备份保存失败,那么redis将停止接受写操作;
#
# If the background saving process will start working again Redis will
# automatically allow writes again.
#
# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.
stop-writes-on-bgsave-error yes
但是,如果你设置了对redis服务器和持久性的适当监控,你可能希望禁用这些特性以便即使存在硬盘、权限等问题,Redis也能照常工作!
# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.
rdbcompression yes
是否采用LZF压缩技术;
# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
# This makes the format more resistant to corruption but there is a performance
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
# for maximum performances.
#
# RDB files created with checksum disabled have a checksum of zero that will
# tell the loading code to skip the check.
rdbchecksum yes
RDB在版本5之后在文件末尾加入了CRC64校验和,这使得格式更抗损坏,但是在保存和加载RDB文件时,性能可能会受到影响(大约10%),因此可以禁用它以获得最大性能;
数据库转储文件名
# The filename where to dump the DB
dbfilename dump.rdb
工作目录:
# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir ./
Redis快照设置:
1.保存到DB的方式;
2.是否采用LZF压缩技术;
3.数据库存储文件名;
4.数据文件存储文件夹;
Tips : 学习一个技术技巧
通用比较函数,支持比较结构体指定字段,支持Linux和Windows
#ifndef _WIN32
#define TYPEOF typeof // linux C98
#else
#define TYPEOF decltype // windows C++11后支持
#endif template <int offset, class TYPE>
bool CheckZero(const void* p)
{
TYPE a = *(*TYPE)((char*)p + offset);
return (bool)a;
} template <int offset, typename T>
int CmpOneKey(const void *p1, const void *p2)
{
T a1 = *(T*)((char*)p1 + offset);
T a2 = *(T*)((char*)p2 + offset); if (a1 < a2)
return -1;
else if (a1 > a2)
return 1;
return 0;
} template <int offset, typename T>
int DescCmpOneKey(const void* p1, const void* p2)
{
return -CmpOneKey<offset, T>(p1, p2);
} template <int offset1, typename T1, int offset2, typename T2>
int CmpTwoKey(const void* p1, const void* p2)
{
int diff = CmpOneKey<offset1, T1>(p1, p2);
if (diff == 0)
{
return CmpOneKey<offset2, T2>(p1, p2);
}
return diff;
} template <int offset1, typename T1, int offset2, typename T2>
int DescCmpTwoKey(const void *p1, const void *p2)
{
return -CmpTwoKey<offset1, T1, offset2, T2>(p1, p2);
} template <int offset1, typename T1, int offset2, typename T2, int offset3, typename T3>
int CmpThreeKey(const void *p1, const void *p2)
{
int diff = CmpTwoKey<offset1, T1, offset2, T2>(p1, p2);
if (diff == 0)
{
return CmpOneKey<offset3, T3>(p1, p2);
}
return diff;
} #define CHECK_ZERO(s, m) CheckZero<offsetof(s, m), TYPEOF(((s*)0)->m)>
#define CMP_ONE_KEY(s, m) CmpOneKey<offsetof(s, m), TYPEOF(((s*)0)->m)>
#define CMP_TWO_KEY(s, m1, m2) CmpTwoKey<offsetof(s, m1), TYPEOF(((s*)0)->m1, offsetof(s, m2), TYPEOF(((s*)0)->m2)>
#define CMP_THREE_KEY(s, m1, m2, m3) CmpThreeKey()<offsetof(s, m1), TYPEOF(((s*)0)->m1, offsetof(s, m2), TYPEOF(((s*)0)->m2), offsetof(s, m3), TYPEOF(((s*)0)->m3>
#define CMP_ONE_KEY_DESC(s, m) DescCmpOneKey<offsetof(s, m), TYPEOF(((s*)0)->m)>
#define CMP_TWO_KEY_DESC(s, m1, m2) DescCmpTwoKey<offsetof(s, m1), TYPEOF(((s*)0)->m1, offsetof(s, m2), TYPEOF(((s*)0)->m2)>
Share : 分享一篇有观点和思考的技术文章
TCP三次握手和SYN攻击:
原文链接:https://mp.weixin.qq.com/s?__biz=MzIwNTc4NTEwOQ==&mid=2247484888&idx=1&sn=aaf4f7f4a0b37c8f823e2665d711dd72&scene=21#wechat_redirect
ARST第三周打卡的更多相关文章
- ARST 第五周打卡
Algorithm : 做一个 leetcode 的算法题 /////////////////////////////////////////////////////////////////// // ...
- [noip2017] 前三周总结
[noip2017] 前三周总结 10.20 Fri. Day -21 距离noip复赛还有3周了,进行最后的冲刺! 首先要说今天过得并不好,和我早上比赛打挂了有关系. 不过每一次比赛都能暴露出我的漏 ...
- 第三周作业(一)VS安装及单元测试练习
第三周作业(一) 需求:练习教科书第22~25页单元测试练习,要求自行安装Visual Studio开发平台,版本至少在2010以上,要求把程序安装过程和练习过程写到博客上,越详细越好,要图文并茂,没 ...
- 三周,用长轮询实现Chat并迁移到Azure测试
公司的OA从零开始进行开发,继简单的单点登陆.角色与权限.消息中间件之后,轮到在线即时通信的模块需要我独立去完成.这三周除了逛网店见爱*看动漫接兼职,基本上都花在这上面了.简单地说就是用MVC4基于长 ...
- Coursera系列-R Programming第三周-词法作用域
完成R Programming第三周 这周作业有点绕,更多地是通过一个缓存逆矩阵的案例,向我们示范[词法作用域 Lexical Scopping]的功效.但是作业里给出的函数有点绕口,花费了我们蛮多心 ...
- JAVA第三周作业(从键盘输入若干数求和)
JAVA第三周作业(从键盘输入若干数求和) 在新的一周,我学习了JAVA的IO编程.下面的代码实现了从键盘输入若干数求和的目标.import java.util.Scanner; public cla ...
- 20145213《Java程序设计》第三周学习总结
20145213<Java程序设计>第三周学习总结 教材学习内容总结 正所谓距离产生美,上周我还倾心于Java表面的基础语法.其简单的流程结构,屈指可数的基本类型分类,早已烂熟于心的运算符 ...
- 20145304 Java第三周学习报告
20145304 <Java程序设计>第三周学习总结 教材学习内容总结 1.定义类: 类定义时使用class关键词,建立实例要使用new关键词. 代码如下: /*定义类 书上例子 衣服的型 ...
- 20145330《Java程序设计》第三周学习总结
20145330 <Java程序设计>第三周学习总结 第三周知识的难度已经逐步上升,并且一周学习两章学习压力也逐渐加大,需要更高效率的来完成学习内容,合理安排时间. 类与对象 对象(Obj ...
随机推荐
- Postman集合/文件夹/请求中脚本的执行顺序
Postman的Collection(集合)/Folder(集合的子文件夹)/Request(请求)中都有Pre-request Script(请求前脚本)和Tests(请求后脚本) 这个功能类似于不 ...
- [51nod1666] 最大值
题面 题解 毒瘤题浪费我大好青春 容易知道, 如果\(l\)和\(r\)位数不一样, 直接选形似\(99..99\)的数, 输出答案即可 \(l\)和\(r\)位数一样的话, 当位数确定的时候, 由于 ...
- Netfilter 之 table、rule、match、target
概述 本文主要分析table,rule,match,target的作用和其数据结构之间的关系,为后面的匹配流程做铺垫,通过本文中代码流程的分析,可以得到如下的关系图: 详细分析 table iptab ...
- 初始html5
一.html5的发展历史: 2004年提出构想:2008年发布第一份草案:2012年前后位推广阶段:2020年最终测试:2022年正式发布. 二.html5新特性: (1)html5 语义化更好: 新 ...
- XGBoost原理简介
XGBoost是GBDT的改进和重要实现,主要在于: 提出稀疏感知(sparsity-aware)算法. 加权分位数快速近似学习算法. 缓存访问模式,数据压缩和分片上的实现上的改进. 加入了Shrin ...
- (转载)完成端口(CompletionPort)详解 - 手把手教你玩转网络编程系列之三
转自:http://blog.csdn.net/piggyxp/article/details/6922277 前 言 本系列里完成端口的代码在两年前就已经写好了,但是由于许久没有写东西了,不知该如何 ...
- SRCNN代码分析
代码是作者页面上下载的matlab版.香港中文大学汤晓鸥教授.Learning a Deep Convolutional Network for Image Super-Resolution. htt ...
- SpringMVC整合SpringFox实践总结
项目中使用的swagger框架在生成api文档时存在一些问题: 1. 控制器下方法无法点击展开 2.api内容结构混乱 基于上述原因,重新整合重构了一下api文档生成的代码.在此将重整过程记录下来,方 ...
- C# 批处理制作静默安装程序包
使用批处理+WinRAR制作静默安装程序包 @echo 安装完窗口会自动关闭!!! @echo off start /wait Lync.exe /Install /Silent start /wai ...
- java 语言实现豆瓣电影信息查询
豆瓣上面有很多电影,有时候要查看个电影信息,去豆瓣搜下还是很方便的,但是如何通过接口的形式来查看豆瓣电影,这对于很多网站.app其实是非常实用的功能,这里笔者附上一个java实现的豆瓣电影信息获取的代 ...