Set - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : OpenMaple : Java Application Programming Interface : Set Class : OpenMaple/Java/Set

Set

OpenMaple representation of a set

 

Description

Method Summary

Examples

Compatibility

Description

• 

The com.maplesoft.openmaple.Set class represents a Maple set.

• 

To create a Set, invoke the toSet method on any Indexable object or cast the result of an evaluate call to Set.

• 

The Set class implements the java.util.Set interface on type Algebraic.

Method Summary

• 

The following methods are defined on Set objects,

• 

Note that Set publicly inherits from Indexable; therefore, it provides all the member functions from the Indexable and Algebraic classes in addition to those listed here.

Algebraic select( int i ) throws MapleException

• 

select returns the element at index i of the set.

• 

The Set class also includes the following methods which implement the java.util.Set interface:

boolean contains( Object value )

• 

contains returns true if value is an Algebraic and the Set contains a value identical to value.

  

This is similar to member except that it accepts an arbitrary Object and does not throw a MapleException.

boolean containsAll( Collection<?> o )

• 

containsAll returns true if every member of the collection o is an Algebraic which is equal to some element of the Set.

java.util.Iterator<Algebraic> iterator()

• 

iterator returns an Iterator object which can be used to iterate over the elements of the Set.

Object[] toArray()

• 

toArray returns an array of objects corresponding to the elements of the Set.

T[] toArray( T[] a )

• 

toArray with an array argument returns an Array populated with the elements of the Set. The runtime type T of this array matches that of the input array a.

Examples

import com.maplesoft.openmaple.*;

import com.maplesoft.externalcall.MapleException;

class Example

{

    public static void main( String notused[] ) throws MapleException

    {

        String[] mapleArgs = { "java" };

        Engine engine = new Engine( mapleArgs, new EngineCallBacksDefault(), null, null );

        Set s = (Set)engine.evaluate( "{1, 17, 37}:" );

        System.out.println("Size of set: " + s.numElements());

        for (Algebraic elem : s) {

            System.out.println("Element: " + elem);

        }

    }

}

Executing this code produces the following output.

Size of set: 3

Element: 1

Element: 17

Element: 37

Compatibility

• 

The Set command was introduced in Maple 2018.

• 

For more information on Maple 2018 changes, see Updates in Maple 2018.

• 

The Set command was updated in Maple 2020.

See Also

OpenMaple

OpenMaple/Java/Algebraic

OpenMaple/Java/API

OpenMaple/Java/Examples

OpenMaple/Java/Expseq

OpenMaple/Java/List

OpenMaple/Java/Table

set