কম্পিউটার টিউটোরিয়াল

C#-এ SortedSet তৈরি করুন

SortedSet<T> একটি সাজানো সেট যা ডুপ্লিকেট অনুমতি দেয় না এবং উপাদানগুলো সাজানো ক্রমে রাখে (বাইনারি সার্চ ট্রি বাস্তবায়ন)। এটি সেট অপারেশন (ইন্টারসেকশন, ইউনিয়ন, ডিফারেন্স) সাপোর্ট করে।

উদাহরণ ১: স্ট্রিং SortedSet এবং এনিউমারেটর

using System;
using System.Collections.Generic;

public class Demo {
    public static void Main(){
        SortedSet set1 = new SortedSet();
        set1.Add("AB");
        set1.Add("BC");
        set1.Add("CD");
        set1.Add("EF");
        
        Console.WriteLine("SortedSet1-এ উপাদানসমূহ...");
        foreach (string res in set1){
            Console.WriteLine(res);
        }
        
        SortedSet set2 = new SortedSet();
        set2.Add("BC");
        set2.Add("CD");
        set2.Add("DE");
        set2.Add("EF");
        set2.Add("AB");
        set2.Add("HI");
        set2.Add("JK");
        
        Console.WriteLine("SortedSet2-এ উপাদানসমূহ (SortedSet-এর জন্য এনিউমারেটর)...");
        SortedSet.Enumerator demoEnum = set2.GetEnumerator();
        while (demoEnum.MoveNext()) {
            string res = demoEnum.Current;
            Console.WriteLine(res);
        }
    }
}

আউটপুট

SortedSet1-এ উপাদানসমূহ...
AB
BC
CD
EF
SortedSet2-এ উপাদানসমূহ (SortedSet-এর জন্য এনিউমারেটর)...
AB
BC
CD
DE
EF
HI
JK

উদাহরণ ২: ইন্টিজার SortedSet এবং RemoveWhere

using System;
using System.Collections.Generic;

public class Demo {
    private static bool demo(int i){
        return ((i % 10) == 0);
    }
    public static void Main(String[] args){
        SortedSet set1 = new SortedSet();
        set1.Add(200);
        set1.Add(215);
        set1.Add(310);
        set1.Add(500);
        set1.Add(600);
        
        Console.WriteLine("SortedSet উপাদানসমূহ...");
        foreach (int i in set1){
            Console.WriteLine(i);
        }
        Console.WriteLine(" ");
        set1.RemoveWhere(demo); // ১০ দিয়ে ভাগ যাবেগুলো মুছে ফেলা
        Console.WriteLine("কিছু উপাদান মুছে ফেলার পর SortedSet...");
        foreach (int i in set1){
            Console.WriteLine(i);
        }
    }
}

আউটপুট

SortedSet উপাদানসমূহ...
200
215
310
500
600
SortedSet কিছু উপাদান মুছে ফেলার পর...
215

বৈশিষ্ট্য: Min, Max, GetViewBetween, IsSubsetOf, IsSupersetOf ইত্যাদি মেথড রয়েছে। পারফরম্যান্সে HashSet-এর চেয়ে ধীর কিন্তু সাজানো অর্ডার মেইনটেইন করে।

  1. C#-তে থ্রেড (Thread) তৈরি

  2. C#-এ ডিকশনারি তৈরি করা (Create a Dictionary)

  3. পাওয়ারপয়েন্টে রেডিয়াল লিস্ট তৈরি করার পদ্ধতি

  4. পাওয়ারপয়েন্টে টাইমলাইন তৈরি করার পদ্ধতি