![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C-C++
紫魔戒
无无
展开
-
vector--C++ STL 学习
vector–C++ STL 学习vector对应的数据结构为数组,而且是动态数组,也就是说我们不必关心该数组事先定义的容量是多少,它的大小会动态增长。与数组类似的是,我们可以在末尾进行元素的添加和删除,也可以进行元素值的随机访问和修改。 vector是STL中最常见的容器,它是一种顺序容器,支持随机访问。vector是一块连续分配的内存,从数据安排的角度来讲,和数组极其相似. 不原创 2017-03-05 21:36:09 · 253 阅读 · 0 评论 -
封装、继承、多态详解
封装、继承、多态(1)封装 封装,也就是把客观事物封装成抽象的类,并且类可以把自己的数据和方法只让可信的类或者对象操作,对不可信的进行信息隐藏。(2)继承 继承是指这样一种能力:它可以使用现有类的所有功能,并在无需重新编写原来的类的情况下对这些功能进行扩展。 继承现有类 + 扩展继承概念的实现方式有三类:实现继承、接口继承和可视继承。 实现继承是指使用基类的属性和方法而无需原创 2017-06-09 14:40:49 · 3385 阅读 · 0 评论 -
LeetCode532. K-diff Pairs in an Array
DescriptionGiven an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both原创 2017-06-08 19:37:46 · 327 阅读 · 0 评论 -
C++中substr函数的用法
substr用法basic_string substr( size_type pos = 0, size_type count = npos ) const; Returns a substring [pos, pos+count). If the requested substring extends past the end of the string, or if count == np原创 2017-05-22 14:24:21 · 1325 阅读 · 0 评论 -
C++ 4种强制类型转换
C++的四种强制类型转换为:static_cast、const_cast、reinterpret_cast和dynamic_cast 类型转换的一般形式:cast-name(expression);static_cast任何具有明确定义的类型转换,只要不包含底层const,都可以使用static_cast; double slope = static_cast(j) / i;注:原创 2017-05-10 07:17:33 · 306 阅读 · 0 评论 -
# 线程安全 & 线程安全函数 & 线程不安全函数
线程安全 & 线程安全函数 & 线程不安全函数 线程安全 就是多线程访问时,采用了加锁机制,当一个线程访问该类的某个数据时,进行保护,其他线程不能进行访问直到该线程读取完,其他线程才可使用。不会出现数据不一致或者数据污染。 如果每次运行结果和单线程运行的结果是一样的,而且其他的变量的值也和预期的是一样的,就是线程安全的。 一个类或者程序所提供的接口对于线程来说是原子操作或者多个线程之间原创 2017-05-15 07:12:57 · 2243 阅读 · 0 评论 -
LeetCode447. Number of Boomerangs
DescriptionGiven n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k(the order原创 2017-04-16 17:50:41 · 266 阅读 · 0 评论 -
int abs(int number)函数有感: 求补码和通过补码求对应的整数 C++(增加:数字的二进制表示中1的个数)
#include "limits.h"#include "math.h"int abs(int number){ int const mask = number >> (sizeof(int) * CHAR_BIT - 1); return (number + mask) ^ mask;} 这是一个求绝对值的函数,看了它不禁想起负数在计算机中的构成. 负数在计算机中是按原创 2017-03-12 16:06:35 · 1516 阅读 · 0 评论 -
map--C++ STL 学习
map–C++ STL 学习 Map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据处理能力。 说下map内部数据的组织,map内部自建一颗红黑树(一种非严格意义上的平衡二叉树),这颗树具有对数据自动排序的功能,所以在map内部所有的数据都是有序的。 map是使用红黑树实现的,访问、查找和删除操作的复杂度都原创 2017-02-26 17:19:43 · 329 阅读 · 0 评论