Last active
December 16, 2015 02:18
-
-
Save kirkconnell/5360899 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::list<int> list; | |
std::list<int>::iterator pos; | |
pos = list.begin(); | |
list.insert(it, 1024); | |
pos = std::find(list.begin(), list.end(), 1024); | |
*pos; // get | |
list.erase(pos); | |
list.front(); | |
list.back(); | |
pos = list.begin(); | |
pos++ // next | |
pos-- // previous | |
list.clear(); | |
list.size(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list = [] | |
list.insert(1, :first) | |
list.index(:first) | |
list.at(1) | |
list.delete_at(1) | |
list.first | |
list.last | |
# previous and next make no sense, since the positions are numeric | |
list.clear | |
list.size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE | |
pos SCROLL CURSOR (pt_id integer) FOR SELECT id FROM pages WHERE page_template_id = pt_id; | |
page_id integer; | |
BEGIN | |
OPEN pos(pt_id := 42); | |
FETCH pos INTO page_id; -- next | |
FETCH LAST FROM pos INTO page_id; -- last | |
FETCH FIRST FROM pos INTO page_id; -- first | |
FETCH ABSOLUTE 10 FROM pos INTO page_id; -- get | |
FETCH PRIOR FROM pos INTO page_id; -- previous | |
-- Direction options: NEXT, PRIOR, FIRST, LAST, ABSOLUTE count, RELATIVE count, FORWARD, or BACKWARD | |
CLOSE pos; | |
END; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::queue<int> queue; | |
for (int i=0; i<5; ++i) queue.push(i); | |
cout << "Popping out elements..."; | |
while (!queue.empty()) | |
{ | |
cout << " " << mystack.front(); // peek | |
mystack.pop(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
queue = [] | |
(0...5).each { |e| queue.push(e) } | |
puts "Popping out elements..." | |
until queue.empty? | |
puts " #{queue.last}" # peek | |
queue.shift # pop | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::stack<int> stack; | |
for (int i=0; i<5; ++i) stack.push(i); | |
cout << "Popping out elements..."; | |
while (!stack.empty()) | |
{ | |
cout << " " << mystack.top(); // peek | |
mystack.pop(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stack = [] | |
(0...5).each { |e| stack.push(e) } | |
puts "Popping out elements..." | |
until stack.empty? | |
puts " #{stack.last}" # peek | |
stack.pop | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment