Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Unified Diff: runtime/bin/set.h

Issue 11365262: Remove unused files. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/builtin_impl_sources.gypi ('k') | runtime/bin/set_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/set.h
===================================================================
--- runtime/bin/set.h (revision 14913)
+++ runtime/bin/set.h (working copy)
@@ -1,128 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-#ifndef BIN_SET_H_
-#define BIN_SET_H_
-
-#include <stdlib.h>
-
-/*
- * Set implements a collection of distinct objects.
- */
-template <class T>
-class Set {
- private:
- struct Node {
- T object_;
- Node* next_;
- };
-
- public:
- class Iterator {
- public:
- explicit Iterator(Set<T>* list) : list_(list) {
- if (list != NULL) {
- next_ = list->head_;
- } else {
- next_ = NULL;
- }
- }
-
- bool HasNext() const {
- return next_ != NULL;
- }
-
- void GetNext(T* entry) {
- *entry = next_->object_;
- next_ = next_->next_;
- }
-
- private:
- const Set<T>* list_;
- struct Node* next_;
- };
-
- Set() {
- head_ = NULL;
- tail_ = NULL;
- size_ = 0;
- }
-
- ~Set() {}
-
- bool Add(const T& element) {
- Node* new_node = new Node;
- new_node->object_ = element;
- new_node->next_ = NULL;
-
- if (Contains(element)) {
- return false;
- }
-
- if (IsEmpty()) {
- head_ = new_node;
- tail_ = new_node;
- } else {
- tail_->next_ = new_node;
- tail_ = new_node;
- }
- size_++;
- return true;
- }
-
- T* Remove(const T& element) {
- Node* current = head_;
- Node* previous = NULL;
- if (IsEmpty()) {
- return NULL;
- }
-
- do {
- if (element == current->object_) {
- if (current == head_) {
- head_ = head_->next_;
- }
- if (current == tail_) {
- tail_ = previous;
- }
- if (previous != NULL) {
- previous->next_ = current->next_;
- }
- size_--;
- return &current->object_;
- }
- previous = current;
- current = current->next_;
- } while (current);
- return NULL;
- }
-
- bool Contains(const T& element) {
- T value;
- Iterator iterator(this);
- while (iterator.HasNext()) {
- iterator.GetNext(&value);
- if (value == element) {
- return true;
- }
- }
- return false;
- }
-
- bool IsEmpty() {
- return head_ == NULL;
- }
-
- int Size() {
- return size_;
- }
-
- private:
- Node* head_;
- Node* tail_;
- int size_;
-};
-
-#endif // BIN_SET_H_
-
« no previous file with comments | « runtime/bin/builtin_impl_sources.gypi ('k') | runtime/bin/set_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698