૵ (Set)
૵ (Set)

૵ (set) ¤×Í ªØ´¢Í§¢éÍÁÙÅã¹áºº·ÕèäÁè͹حҵ ãËé«éӡѹ áÅÐäÁèàÃÕ§ÅӴѺ ¨Ö§ÁÕ¡ÒÃãªé૵ÁÒªèÇÂ㹡ÒõÃǨÊͺ¡ÒëéӢͧ¢éÍÁÙÅ

µÑÇÍÂèÒ§¢Í§à«µ ¤×Í Çѹã¹ÊÑ»´ÒËì à´×͹ã¹Ë¹Öè§»Õ »Õ¹Ñ¡Éѵà à¾È µÓá˹觷ҧÇÔªÒ¡Òà ÃÒª×èÍÍÓàÀÍ㹨ѧËÇÑ´ ÍÒªÕ¾ àª×éÍªÒµÔ ÊÑ­ªÒµÔ

µÑÇÍÂèÒ§ : ¡ÒûÃСÒÈ áÅÐàÃÕ¡ãªé૵´éÇ Java
// Set in Java Language
// you can test this code in http://www.ideone.png
Set<Integer> numbers = new TreeSet<Integer>();
numbers.add(2);
numbers.add(5);
System.out.println(numbers); // "[2, 5]"
System.out.println(numbers.contains(7)); // "false"
System.out.println(numbers.contains(5)); // "true"
System.out.println(numbers.add(5)); // "false"
System.out.println(numbers.size()); // "2"
int sum = 0;
for (int n : numbers) { sum += n; }
System.out.println("Sum = " + sum); // "Sum = 7"
numbers.addAll(Arrays.asList(1,2,3,4,5));
System.out.println(numbers); // "[1, 2, 3, 4, 5]"
numbers.removeAll(Arrays.asList(4,5,6,7));
System.out.println(numbers); // "[1, 2, 3]"
numbers.retainAll(Arrays.asList(2,3,4,5));
System.out.println(numbers); // "[2, 3]"
µÑÇÍÂèÒ§ : ¡ÒûÃСÒÈ áÅÐàÃÕ¡ãªé૵´éÇ Javascript
<!-- Set in Java Language
you can test this code in http://www.w3schools.com/js/tryit.asp?filename=tryjs_myfirst
code from https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Set
-->
<html><head>
<script>
function myset() {
var out = "";
var mySet 
mySet = new Set();
mySet.add(1);
mySet.add(5);
mySet.add("some text");
mySet.add(6);
out += mySet.has(1); // true
out += mySet.has(3); // false, 3 has not been added to the set
out += mySet.has(5);              // true
out += mySet.has(Math.sqrt(25));  // true
out += mySet.has("Some Text".toLowerCase()); // true
out += mySet.has(6); // true
out += mySet.size; // 4
mySet.delete(5); // removes 5 from the set
out += mySet.has(5);    // false, 5 has been removed
out += mySet.size; // 3, we just removed one value
out += "<br/>";
for (let item of mySet) { out += (item); }
return out;
}
</script>
</head><body>
<button type="button"
onclick="document.getElementById('demo').innerHTML = myset()">Click me</button>
<p id="demo"></p>
</body>
</html> 
programiz.com/python-programming/set ·ÕèàÇçºä«µì programiz.com ͸ԺÒ¤ÇÒÁËÁÒ ÁÕµÑÇÍÂèÒ§ áÅÐ IPython Shell ãËé·´Êͺ»ÃÐÁÇżŠcode .py à¢éÒä»ÍèÒ¹àÃ×èͧ set ¾º¤ÇÒÁËÁÒÂÇèÒ A set is an unordered collection of items. Every element is unique (no duplicates) and must be immutable (which cannot be changed). However, the set itself is mutable. We can add or remove items from it. Sets can be used to perform mathematical set operations like union, intersection, symmetric difference etc. ÁÕ build-in function ÊÓËÃѺ set ÍÒ·Ô all(), any(), enumerate(), len(), max(), min(), sorted(), sum()
# set of integers
my_set = {1, 2, 3}
print(my_set)

# set of mixed datatypes
my_set = {1.0, "Hello", (1, 2, 3)}
print(my_set)

# initialize a with {}
a = {}

# check data type of a
# Output: <class 'dict'>
print(type(a))

# initialize a with set()
a = set()

# check data type of a
# Output: <class 'set'>
print(type(a))

# code from programiz.com
àÍ¡ÊÒéºÑºàµçÁ (Full Text)

ÃÈ.´Ã.ÊÁªÒ »ÃÐÊÔ·¸Ôì¨ÙµÃСÙÅ

Bruno R. Preiss

Mark Allen Weiss

William H. Ford

DB: ¾Ñ²³×þÕ

Michael Mcmillan
àÍ¡ÊÒÃÍéÒ§ÍÔ§ (Reference)
[1] âÍÀÒÊ àÍÕèÂÁÊÔÃÔǧÈì, "â¤Ã§ÊÃéÒ§¢éÍÁÙÅ (Data Structures) à¾×èÍ¡ÒÃÍ͡Ẻâ»Ãá¡ÃÁ¤ÍÁ¾ÔÇàµÍÃì", ºÃÔÉÑ· «ÕàÍç´ÂÙपÑè¹ ¨Ó¡Ñ´., ¡Ãا෾Ï, 2549.
[2] Michael McMillan, "Data Structures and Algorithms with JavaScript", O’Reilly Media, Inc., USA., 2014.
[3] Loiane Groner, "Learning JavaScript Data Structures and Algorithms", Packt Publishing, 2014.

http://goo.gl/72BPC