-Type_Struct::Type_Struct(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int* block_lengths, MPI_Aint* block_indices, MPI_Datatype* old_types): Datatype(size, lb, ub, flags), block_count_(count), block_lengths_(block_lengths), block_indices_(block_indices), old_types_(old_types){
- block_lengths_= new int[count];
- block_indices_= new MPI_Aint[count];
- old_types_= new MPI_Datatype[count];
+Type_Indexed::Type_Indexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, const int* block_lengths,
+ const int* block_indices, MPI_Datatype old_type)
+ : Type_Hindexed(size, lb, ub, flags, count, block_lengths, block_indices, old_type, old_type->get_extent())
+{
+ delete contents_;
+ int* ints = new int[2*count+1];
+ ints[0]=count;
+ for(int i=1;i<=count;i++)
+ ints[i]=block_lengths[i-1];
+ for(int i=count+1;i<=2*count;i++)
+ ints[i]=block_indices[i-count-1];
+ contents_ = new Datatype_contents(MPI_COMBINER_INDEXED, 2*count+1, ints, 0, nullptr, 1, &old_type);
+ delete[] ints;
+}
+
+int Type_Indexed::clone(MPI_Datatype* type)
+{
+ *type = new Type_Indexed(this->size(), this->lb(), this->ub(), this->flags(), this->block_count_, this->block_lengths_, (int*)(this->block_indices_), this->old_type_);
+ (*type)->copy_attrs(this);
+ return MPI_SUCCESS;
+}
+
+Type_Struct::Type_Struct(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, const int* block_lengths,
+ const MPI_Aint* block_indices, const MPI_Datatype* old_types)
+ : Datatype(size, lb, ub, flags)
+ , block_count_(count)
+ , block_lengths_(new int[count])
+ , block_indices_(new MPI_Aint[count])
+ , old_types_(new MPI_Datatype[count])
+{
+ int* ints = new int[count+1];
+ ints[0]=count;
+ for(int i=1;i<=count;i++)
+ ints[i]=block_lengths[i-1];
+ contents_ = new Datatype_contents(MPI_COMBINER_INDEXED, count+1, ints, count, block_indices, count, old_types);
+ delete[] ints;