
C Related Language
随遇而安随缘一世
这个作者很懒,什么都没留下…
展开
-
STL--集和多集(set/multiset)
与基本容器相比,关联容器更注重快速和高效地检索数据的能力。这些容器是根据键值(key)来检索数据的,键可以是值也可以是容器中的某一成员。这一类中的成员在初始化后都是按一定顺序排好序的。本文地址:http://www.cnblogs.com/archimedes/p/cpp-set-multiset.html,转载请注明源地址。set和multiset 容器类(集和多集):#incl转载 2015-11-03 05:29:16 · 1122 阅读 · 0 评论 -
std::unique
Defined in header template class ForwardIt >ForwardIt unique( ForwardIt first, ForwardIt last );(1) template class ForwardIt, class BinaryPredicate >ForwardIt uniqu转载 2015-01-15 01:30:47 · 557 阅读 · 0 评论 -
Int data type
Data Type Ranges on MSDN:signed char: -127 to 127 (note, not -128 to 127; this accommodates 1's-complement platforms)unsigned char: 0 to 255"plain" char: -127 to 127 or 0 to 255 (depen转载 2014-12-10 07:16:08 · 664 阅读 · 0 评论 -
C++ STL map的使用
1、map简介map是一类关联式容器。它的特点是增加和删除节点对迭代器的影响很小,除了那个操作节点,对其他的节点都没有什么影响。对于迭代器来说,可以修改实值,而不能修改key。2、map的功能自动建立Key - value的对应。key 和 value可以是任意你需要的类型。根据key值快速查找记录,查找的复杂度基本是Log(N),如果有1000个记录,最多查找10次,1,000,转载 2015-01-13 05:58:51 · 498 阅读 · 0 评论 -
hash与map的区别联系应用
一,hashtable原理:哈希表又名散列表,其主要目的是用于解决数据的快速定位问题。考虑如下一个场景。一列键值对数据,存储在一个table中,如何通过数据的关键字快速查找相应值呢?不要告诉我一个个拿出来比较key啊,呵呵。大家都知道,在所有的线性数据结构中,数组的定位速度最快,因为它可通过数组下标直接定位到相应的数组空间,就不需要一个个查找。而哈希表就是利用数组这个能转载 2014-12-17 01:50:42 · 540 阅读 · 0 评论 -
C++ STL中哈希表 hash_map介绍
0 为什么需要hash_map用过map吧?map提供一个很常用的功能,那就是提供key-value的存储和查找功能。例如,我要记录一个人名和相应的存储,而且随时增加,要快速查找和修改:岳不群-华山派掌门人,人称君子剑张三丰-武当掌门人,太极拳创始人东方不败-第一高手,葵花宝典...这些信息如果保存下来并不复杂,但是找起来比较麻烦。例如我要找"张三丰"的信息,最傻的方法就转载 2014-12-17 01:52:18 · 537 阅读 · 0 评论 -
opengmtest/infer.hxx
548 lines (487 sloc) 18.597 kbRawBlameHistory // // Created by Toru Tamaki on 2013/11/28. // Copyright (c) 2013 tamaki. All rights reserved. /转载 2014-08-22 15:12:15 · 1260 阅读 · 0 评论 -
*** glibc detected *** double free ....
*** glibc detected *** free(): invalid pointer:*** glibc detected *** malloc(): memory corruption:*** glibc detected *** double free or corruption (out): 0x00000000005c18a0 ****** glibc detected转载 2014-08-10 09:46:04 · 651 阅读 · 0 评论 -
关于C++ const 的全面总结
C++中的const关键字的用法非常灵活,而使用const将大大改善程序的健壮性,本人根据各方面查到的资料进行总结如下,期望对朋友们有所帮助。Const 是C++中常用的类型修饰符,常类型是指使用类型修饰符const说明的类型,常类型的变量或对象的值是不能被更新的。 一、Const作用 如下表所示:No.作用说明参考代码转载 2014-07-28 22:42:49 · 497 阅读 · 0 评论 -
How to use Boost in Visual Studio 2010
339down voteacceptedWhile Nate's answer is pretty good already, I'm going to expand on it more specifically for Visual Studio 2010 as requested, and include information on compiling in t转载 2014-07-16 02:01:33 · 1215 阅读 · 0 评论 -
How to install the C++ Boost Libraries on Windows
Boost is a set of high-quality libraries that speed up C++ development. They are included in most linux distributions and some of them are already part of the C++ Standard Library. In the Windows envi转载 2014-07-15 12:58:53 · 967 阅读 · 0 评论 -
有关g++的-rdynamic选项
选项 -rdynamic 用来通知链接器将所有符号添加到动态符号表中 (目的是能够通过使用 dlopen 来实现向后跟踪) -rdynamic Pass the flag ‘-export-dynamic’ to the ELF linker, on targets that support it. This instructs the linker to add all symb转载 2014-07-27 23:58:23 · 6521 阅读 · 0 评论 -
友元函数(friend)
类的外部,也就是通过实例来访问私有(private)或保护(protected)成员,这是被禁止的。但从实用性来说,的确有时很需要在外部访问,C++增加了一种称之为“友元(friend)”函数的申明,将“特权”赋给一些函数(可以是全局函数,也可以是其它类的成员函数),使之能够访问该类的私有和保护成员。友元函数必须在类里面申明,而且友元函数一定不是该类的成员函数。因此,这样的“特权”实际上已转载 2014-06-17 03:49:08 · 697 阅读 · 0 评论 -
CMake Tutorial
Contents Introduction Getting Started IDE Integration GUI Tool Libraries and Subdirectories Functionally Improved TestingIntroductionWhat is CMake?According to CM转载 2014-07-25 08:55:34 · 659 阅读 · 0 评论 -
Overloading the << Operator for Your Own Classes
Output streams use the insertion () operator for standard types. You can also overload the operator for your own classes.ExampleThe write function example showed the use of a Date s转载 2014-06-17 03:44:21 · 586 阅读 · 0 评论 -
CMake Tutorial – Chapter 1: Getting Started
ContentsIntroductionInstallationWindowsDownload and InstallCygwinMac OS XDownload and InstallHomebrewLinuxUbuntu (Debian)Red Hat/CentOSFedora转载 2014-07-25 08:56:32 · 1507 阅读 · 0 评论 -
.arr
public static double[,] ReadDoubleArray(string filename) { using (FileStream fstream = File.OpenRead(filename)) { using (BinaryReader reader = new B转载 2014-06-14 03:10:09 · 629 阅读 · 0 评论 -
Save and read double array in a binary file
#include #include using namespace std;int main(){ double fnum[4] = {9.5, -3.4, 1.0, 2.1}; int i; ofstream out("numbers", ios::out | ios::binary); if(!out) { cout "Cannot o转载 2014-06-13 02:24:06 · 1250 阅读 · 0 评论 -
【leetcode】Palindrome Number
Question:Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the转载 2014-12-11 02:31:03 · 469 阅读 · 0 评论 -
LeetCode || Single Number II
Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using转载 2015-02-07 06:55:34 · 494 阅读 · 0 评论 -
eetCode] Basic Calculator & Basic Calculator II Basic Calculator
Basic CalculatorImplement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative转载 2015-09-18 03:29:11 · 902 阅读 · 0 评论 -
Count Complete Tree Nodes
http://bookshadow.com/weblog/2015/06/06/leetcode-count-complete-tree-nodes/转载 2015-09-18 03:55:15 · 660 阅读 · 0 评论 -
Implement Queue using Stacks
A queue can be implemented using two stacks. Let queue to be implemented be q and stacks used to implement q be stack1 and stack2. q can be implemented in two ways:Method 1 (By making enQueue oper转载 2015-09-17 22:36:50 · 697 阅读 · 0 评论 -
[LeetCode] Shortest Palindrome 最短回文串
Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.For exam转载 2015-09-18 06:27:49 · 1141 阅读 · 0 评论 -
Contains Duplicate III
Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference between i and转载 2015-09-18 04:21:41 · 812 阅读 · 0 评论 -
Leetcode: Product of Array Except Self (60ms) analysis and solution
Problem:Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements ofnums except nums[i].Solve it withou转载 2015-09-17 23:13:20 · 580 阅读 · 0 评论 -
SINGLE NUMBER I & II & III
Single Number I :Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement转载 2015-09-17 22:26:55 · 2324 阅读 · 3 评论 -
Implement stack using a queue
The puzzle is to implement basic stack operations with using only basic queue operations. That is, a queue object is given, we need construct a wrapper for the stack functions, push, pop, which will o转载 2015-09-09 03:21:26 · 879 阅读 · 0 评论 -
Numerical Integration
This chapter describes routines for performing numerical integration (quadrature) of a function in one dimension. There are routines for adaptive and non-adaptive integration of general functions, wit转载 2015-04-06 02:07:39 · 869 阅读 · 0 评论 -
使用MKL求解矩阵的行列式值与逆
在FORTRAN下有很多求矩阵行列式值以及逆的方法,这些方法包括自己写程序求解,使用如IMSL和MKL等下面的库函数求解。一般来说,使用IMSL求解矩阵的行列式值和逆最简单且速度适中,但是IMSL现在属于商业库,如果程序自己用可以通过一些方法来免费使用,但是若涉及版权,买的话还是挺贵的。使用MKL的话,从在我电脑上的测试来看,速度最快,但是用起来稍微复杂一些,如果你是非商业目的(non-comme转载 2015-04-01 10:36:32 · 13532 阅读 · 1 评论 -
Some examples of BLAS and LAPACK calls from C++.
We have several multiprocessor machines with Intel's Math Kernel Library (MLK), processor specific compilers, and threading libraries (e.g., OMP). The examples below show how to set up your data struc转载 2015-04-01 10:37:53 · 972 阅读 · 0 评论 -
windows下PTAM的编译
前些日子在研究PTAM,下面首先说说PTAM的编译过程,我在XP几WIN7搭配vs2010中均已测试过,都可以运行。首先下载编译PTAM所必须的库文件,下载地址我会给出PTAM(PTAM.zip)http://www.robots.ox.ac.uk/~gk/PTAM/GLEW(glew-1.5.0-win32.zip)http://glew.sourceforge.net/转载 2015-03-13 07:16:33 · 2929 阅读 · 3 评论 -
经典的7种排序算法 原理C++实现
排序是编程过程中经常遇到的操作,它在很大程度上影响了程序的执行效率。目前关于排序的算法有很多,其中不乏非常精妙的算法。但是总体来说,作为一个计算机相关专业的学习者来说,必须要知道而且会亲自动手去实现7种常见的算法。这不管对自己编程能力的提高还是日后的实习就业都会有莫大的帮助。7种常见的排序算法大致可以分为两类:第一类是低级排序算法,有选择排序、冒泡排序、插入排序;第二类是高级排序算法,有堆排序转载 2015-02-24 12:04:35 · 765 阅读 · 0 评论 -
Manacher's ALGORITHM
文章转载于Felix's Blog,在此谢过,便于理解,文章有稍微改动。Manacher's ALGORITHM: O(n)时间求字符串的最长回文子串首先用一个非常巧妙的方式对子串预处理:(1)将所有可能的奇数/偶数长度的回文子串都转换成了奇数长度:在每个字符的两边都插入一个特殊的符号。比如 abba 变成 #a#b#b#a#, aba变成 #a#b#a#。转载 2015-02-24 00:04:24 · 352 阅读 · 0 评论 -
[LeetCode] Largest Rectangle in Histogram 解题报告
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width of转载 2015-02-24 01:33:51 · 448 阅读 · 0 评论 -
Manacher’s algorithm
LeetCode上一道求回文字符串的问题,通常容易想到的是暴力和动态规划的方法,时间复杂度为O(n^2),后来看到有一种更巧妙的算法,Manacher’s algorithm,时间复杂度为O(n)。参考大神的博客,记下来自己的理解,方便日后查阅。1.预处理首先,由于通常情况下,对于奇数长度和偶数长度的不同字符串,我们需要分别处理。这里,通过巧妙的预处理,在每一个字符两边增加一个特殊转载 2015-02-23 23:52:39 · 486 阅读 · 0 评论 -
LONGEST VALID PARENTHESES
Problem:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring转载 2015-02-20 12:24:25 · 473 阅读 · 0 评论 -
Debugging with RStudio
OverviewRStudio includes a visual debugger that can help you understand code and find bugs. The debugger includes the following features:Editor breakpoints, both inside and outside functionsCo转载 2014-05-30 04:15:47 · 2974 阅读 · 0 评论 -
R编辑器Rstudio学习笔记——基本功能与操作
为了为参加supstat夏令营,今天特地熟悉了和R语言配套的编辑器Rstudio。以前只闻其声,未见其貌,今天试用一下,发现界面简单清晰,既能帮助初学者熟悉函数,也能对复杂的程序结构进行优化,方便阅读。 Rstudio界面如下所示,简单地分为四个窗口,从左至右分别是程序编辑窗口,工作空间与历史信息,程序运行与输出窗口(主界面),画图和函数包帮助窗口。1. 主界面(Consol转载 2014-05-30 04:11:30 · 23213 阅读 · 0 评论 -
vector清空
转自:http://blog.youkuaiyun.com/metalkittie/article/details/3115750注:使用过低三种方法,可行!vector int> vecInt; for (int i=0;i { vecInt.push_back(i); } int j= vecInt.capacity(); //j=512转载 2013-06-06 02:54:50 · 587 阅读 · 0 评论