Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
amma2
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
struct node { int key; int value; node* next; node* prev; }; class Cache { map<int, node*> m; node* head; node* tail; public: void put(int key, int value) { tail->next = new node(key, value); m[key] = tail->next; node* tmp = tail; tail = tail->next; tail->prev = tmp; } int get(int key) { } void remove(int key) { if (m.find(key) != m.end()) { if (m[key] == head) { node* tmp = head; head = head->next; delete tmp; } else if (m[key] == tail) { node* tmp = tail; tail = tail->prev; delete tmp; } else { node* tmp = m[key]; tmp->next->prev = tmp->prev; tmp->prev->next = tmp->next; delete m[key]; } m.erase(key); } } };
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
fork mode
|
history
|
discussion