Home› X++ Programming Language› / Programs / Use of domainSet method
🚀 Programming Example

Use of domainSet method

149 Views
Beginner
Code Snippet

Use of domainSet method

📌 Information & Algorithm

Use of domainSet method

Creates a set of the key (domain) values in a map

Given Input:

       map.insert (1,"Rumman");
       map.insert (2,"Osman");
       map.insert (3,"Musar");
       map.insert (4,"Inzamamul");
       map.insert (5,"Hassan");

Expected Output:

domain value 1
domain value 2
domain value 3
domain value 4
domain value 5

💻 Program Code

static void SampleMap (Args _args)
{
    Set               set;
    SetEnumerator      enumerator;
    Map map = new Map (Types::Integer, Types::String);
       
       map.insert (1,"Rumman");
       map.insert (2,"Osman");
       map.insert (3,"Musar");
       map.insert (4,"Inzamamul");
       map.insert (5,"Hassan");

    set= map.domainSet();
    enumerator = set.getEnumerator();

    while (enumerator.moveNext())
    {
            info(strFmt(" domain value %1",enumerator.current()));

    }

}

🖥 Program Output

                                domain value 1
domain value 2
domain value 3
domain value 4
domain value 5
                            
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.