gmp_lib.mpz_swap Method

GMP Native Interface for .NET

gmp_libmpz_swap Method
Swap the values rop1 and rop2 efficiently.

Namespace:  Math.Gmp.Native
Assembly:  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static void mpz_swap(
	mpz_t rop1,
	mpz_t rop2
)
Public Shared Sub mpz_swap ( 
	rop1 As mpz_t,
	rop2 As mpz_t
)
public:
static void mpz_swap(
	mpz_t^ rop1, 
	mpz_t^ rop2
)
static member mpz_swap : 
        rop1 : mpz_t * 
        rop2 : mpz_t -> unit 

Parameters

rop1
Type: Math.Gmp.Nativempz_t
The first integer.
rop2
Type: Math.Gmp.Nativempz_t
The second integer.
Examples
// Create, initialize, and set a new integer x to 10.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_si(x, 10);

// Create, initialize, and set a new integer x to -210.
mpz_t y = new mpz_t();
gmp_lib.mpz_init_set_si(y, -210);

// Swap the values of x and y.
gmp_lib.mpz_swap(x, y);

// Assert that the values have been swapped.
Assert.IsTrue(gmp_lib.mpz_get_si(x) == -210);
Assert.IsTrue(gmp_lib.mpz_get_si(y) == 10);

// Release unmanaged memory allocated for x and y.
gmp_lib.mpz_clears(x, y, null);
' Create, initialize, and set a new integer x to 10.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_si(x, 10)

' Create, initialize, and set a new integer x to -210.
Dim y As New mpz_t()
gmp_lib.mpz_init_set_si(y, -210)

' Swap the values of x and y.
gmp_lib.mpz_swap(x, y)

' Assert that the values have been swapped.
Assert.IsTrue(gmp_lib.mpz_get_si(x) = -210)
Assert.IsTrue(gmp_lib.mpz_get_si(y) = 10)

' Release unmanaged memory allocated for x and y.
gmp_lib.mpz_clears(x, y, Nothing)

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

See Also