Skip to content

Commit aec370f

Browse files
committed
cpp: make set and map doc a bit better
1 parent 728bdd3 commit aec370f

3 files changed

Lines changed: 28 additions & 27 deletions

File tree

‎cpp/map.cpp‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
/*
22
# map
33
4-
http://www.cplusplus.com/reference/map/map/
4+
http://www.cplusplus.com/reference/map/map/
55
6-
Also comes in an unordered version `unordered_map`.
6+
Also comes in an unordered version `unordered_map`.
77
8-
Ordered.
8+
Ordered.
99
10-
Also comes in an multiple value input version `multimap`.
10+
Also comes in an multiple value input version `multimap`.
1111
12-
Does not require a hash function. Usually implemented as a self balancing tree such as a rb tree.
12+
Does not require a hash function. Usually implemented as a self balancing tree such as a rb tree.
1313
1414
# hashmap
1515
16-
There seems to be no explicit hashmap container, only a generic map interface,
16+
There seems to be no explicit hashmap container, only a generic map interface,
1717
18-
However unordered_map is likely to be hashmap based.
18+
However unordered_map is likely to be hashmap based.
1919
20-
A nonstandard `hash_map` already provided with gcc and msvc++.
21-
It is placed in the `std::` namespace, but it is *not* ISO.
20+
A nonstandard `hash_map` already provided with gcc and msvc++.
21+
It is placed in the `std::` namespace, but it is *not* ISO.
2222
*/
2323

2424
#include "common.hpp"
@@ -76,7 +76,7 @@ int main() {
7676
}
7777

7878
/*
79-
emplace
79+
# emplace
8080
8181
Put a value pair into the map without creating the pair explicitly.
8282

‎cpp/set.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
22
# set
33
4-
- unique elements: inserting twice does nothing
4+
Implemented with Red Black trees in GCC 6.4:
5+
https://stackoverflow.com/questions/2558153/what-is-the-underlying-data-structure-of-a-stl-set-in-c/51944661#51944661
56
6-
- always ordered: $O(log)$ find / insert
7+
A hashtable would be unlikely because it is sorted and can be efficiently iterated.
78
8-
- immutable elements: it is not possible to modify an object,
9-
one must first remove it and resinsert.
9+
Unique elements: inserting twice does nothing.
1010
11-
This is so because modification may mean reordering.
11+
Immutable elements: it is not possible to modify an object, one must first remove it and resinsert. This is so because modification may mean reordering.
1212
*/
1313

1414
#include "common.hpp"
@@ -81,7 +81,7 @@ int main() {
8181
/*
8282
# insert
8383
84-
Return is a pair conatining:
84+
Return is a pair containing:
8585
8686
- if the item was not present, an iterator to the item inserted and true
8787
- if the item was present, an iterator to the existing item inserted and false

‎gcc/build.md‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,36 @@ How to build GCC from source.
44

55
Tested with: version 5.1.0 on Ubuntu 14.04 in a 2013 computer.
66

7-
Summary:
7+
Summary local build:
88

99
sudo apt-get build-dep gcc
1010
# Required to compile gnat.
1111
sudo apt-get install gnat-4.8
12-
mkdir gcc
12+
git clone git://gcc.gnu.org/git/gcc.git
1313
cd gcc
14-
git clone git://gcc.gnu.org/git/gcc.git src
15-
cd src
1614
# No annotated tags... so no describe.
1715
git checkout gcc-5_1_0-release
1816
./contrib/download_prerequisites
19-
cd ..
2017
mkdir build
2118
cd build
2219
# C and C++ only.
23-
../src/configure --enable-languages=c,c++ --prefix="$(pwd)/../install"
20+
../configure --enable-languages=c,c++ --prefix="$(pwd)/install"
2421
# Add a suffix to the executable names:
2522
# --program-suffix="-4.7"
2623
# All languages.
27-
# ../src/configure --enable-languages=all --prefix="$(pwd)/../install"
24+
# ../configure --enable-languages=all --prefix="$(pwd)/install"
2825
# Wait hours.
29-
make -j5
26+
make -j$(nproc)
27+
3028
# Wait hours.
31-
make check
29+
#make check
30+
3231
# Install executables to /usr/local/bin
3332
# There are also many other installed files under /usr/local.
34-
sudo make install
35-
gcc -v
33+
make install
34+
35+
# Use it.
36+
./install/bin/gcc -v
3637
# sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
3738

3839
Or install locally for interactive testing:

0 commit comments

Comments
 (0)