Skip to content

Commit 06a4584

Browse files
committed
Add chrono
1 parent 2dc551a commit 06a4584

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ a.first; // "hello"
447447
a.second; // 3
448448
```
449449
450-
## `map` (associative array - usually implemented as binary search trees)
450+
## `map` (associative array - usually implemented as binary search trees - avg. time complexity: O(log n))
451451
452452
```cpp
453453
#include <map> // Include map (std namespace)
@@ -458,7 +458,7 @@ for (auto& p:a)
458458
a.size(); // 1
459459
```
460460

461-
## `unordered_map` (associative array - usually implemented as hash table)
461+
## `unordered_map` (associative array - usually implemented as hash table - avg. time complexity: O(1))
462462

463463
```cpp
464464
#include <unordered_map> // Include map (std namespace)
@@ -469,7 +469,7 @@ for (auto& p:a)
469469
a.size(); // 1
470470
```
471471

472-
## `set` (store unique elements - usually implemented as binary search trees)
472+
## `set` (store unique elements - usually implemented as binary search trees - avg. time complexity: O(log n))
473473

474474
```cpp
475475
#include <set> // Include set (std namespace)
@@ -480,7 +480,7 @@ if (s.find(123) != s.end()) // Search for an element
480480
cout << s.size(); // Number of elements in set
481481
```
482482

483-
## `unordered_set` (store unique elements - usually implemented as a hash set)
483+
## `unordered_set` (store unique elements - usually implemented as a hash set - avg. time complexity: O(1))
484484

485485
```cpp
486486
#include <unordered_set> // Include set (std namespace)
@@ -501,3 +501,18 @@ sort(a, a+n); // Sort array a[0]..a[n-1] by <
501501
sort(a.begin(), a.end()); // Sort vector or deque
502502
reverse(a.begin(), a.end()); // Reverse vector or deque
503503
```
504+
505+
## 'chrono' (Time related library)
506+
```cpp
507+
#include <chrono> // Include chrono
508+
using namespace chrono; // Use namespace
509+
auto from = // Get current time_point
510+
high_resolution_clock::now();
511+
// ... do some work
512+
auto to = // Get current time_point
513+
high_resolution_clock::now();
514+
using ms = // Compute duration in milliseconds
515+
duration<float, milliseconds::period>;
516+
cout << duration_cast<ms>(to - from)
517+
.count() << "ms";
518+
```

0 commit comments

Comments
 (0)