Clear (set)

From SwiftAPI

Jump to: navigation, search

Contents

C++

#include <set>
#include <string>
using namespace std;
 
set<string> s;
s.insert("foo");
s.insert("bar");
s.clear();
int n = s.size();
// n == 0

Java

import java.util.*;
 
Set<String> s = new HashSet<String>(Arrays.asList("foo", "bar"));
s.clear();
int n = s.size()
// n == 0

Objective-C

developer.apple.com

- (void)removeAllObjects
NSMutableSet *s = [NSMutableSet setWithObjects:@"foo", @"bar", nil];
[s removeAllObjects];
int n = s.count;
// n == 0

Python

docs.python.org

s = set(['foo', 'bar'])
s.clear()
n = len(s)
# n == 0

Ruby

Ruby-Doc.org

require 'set'
 
s = Set.new(['foo', 'bar'])
s.clear()
n = s.length
# n == 0

Swift

var s : Set<String> = ["foo", "bar"]
s.removeAll()
let n = s.count
// n == 0
Personal tools