当前位置: 首页>>代码示例>>C++>>正文


C++ Partition类代码示例

本文整理汇总了C++中Partition的典型用法代码示例。如果您正苦于以下问题:C++ Partition类的具体用法?C++ Partition怎么用?C++ Partition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Partition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: collect_vertex_partitions

void collect_vertex_partitions(const Partition& P,      // in
			       Vtx2PartMap    & p_of_v, // out 
			       bool mark_on_boundary)   // int
{
  typedef typename Partition::PartBdVertexIterator PartBdVertexIterator;
  typedef typename Partition::grid_type   grid_type;
  typedef grid_types<grid_type>           gt;
  typedef typename gt::CellIterator             CellIterator;
  typedef typename gt::VertexOnCellIterator     VertexOnCellIterator;

  typedef BoundaryRange<grid_type>              BdRange;
  typedef typename BdRange::VertexIterator      BdVertexIterator;

  BdRange Bd(P.TheGrid());

  // add mark for vertices on grid boundary
  if(mark_on_boundary) {
    for(BdVertexIterator bv = Bd.FirstVertex(); ! bv.IsDone(); ++bv)
      p_of_v[*bv].push_back(-1);
  }
  for(CellIterator c = P.TheGrid().FirstCell(); ! c.IsDone(); ++c)
    for(VertexOnCellIterator vc = (*c).FirstVertex(); ! vc.IsDone(); ++vc) {
      int pt = P.partition(*c);
      if(std::find(p_of_v[*vc].begin(),p_of_v[*vc].end(),pt) == p_of_v[*vc].end())
	p_of_v[*vc].push_back(pt);
    }

  /*
  // add mark for vertices on boundary of partitions
  for(int pt = 0; pt < (int)P.NumOfPartitions(); ++pt) {
    for(PartBdVertexIterator pbv = P.FirstBdVertex(pt); ! pbv.IsDone(); ++pbv)
      partitions_of_vertex[*pbv].push_back(pt);
  }
  */
}
开发者ID:BackupTheBerlios,项目名称:gral,代码行数:35,代码来源:collect-element-partitions.C

示例2: zetaFine

Partition ClusteringProjector::projectBackToFinest(const Partition& zetaCoarse,
		const std::vector<std::vector<node> >& maps, const Graph& Gfinest) {
	if (zetaCoarse.numberOfElements() == Gfinest.numberOfNodes()) {
		return zetaCoarse;
	}

	Partition zetaFine(Gfinest.upperNodeIdBound()); //Gfinest.numberOfNodes()
	zetaFine.setUpperBound(zetaCoarse.upperBound()); // upper bound for ids in zetaFine must be set to upper bound of zetaCoarse, or modularity assertions fail

	// store temporarily coarsest supernode here
	std::vector<node> tempMap(Gfinest.upperNodeIdBound()); //Gfinest.numberOfNodes()

	// initialize to identity
	Gfinest.parallelForNodes([&](node v){
		tempMap[v] = v;
	});

	// find coarsest supernode for each node
	for (auto iter = maps.begin(); iter != maps.end(); ++iter) {
		Gfinest.parallelForNodes([&](node v){
			tempMap[v] = (* iter)[tempMap[v]];
		});
	}


	// set clusters for fine nodes
	Gfinest.parallelForNodes([&](node v) {
		index sc = zetaCoarse[tempMap[v]];
		zetaFine.addToSubset(sc,v);//zetaFine[v] = sc;
	});

	return zetaFine;
}
开发者ID:maxvogel,项目名称:NetworKit-mirror2,代码行数:33,代码来源:ClusteringProjector.cpp

示例3: communicationGraph

Graph communicationGraph(const Graph& graph, Partition &zeta) {
	zeta.compact();
	count n = zeta.numberOfSubsets();
	Graph commGraph(n);

	if (graph.isWeighted()) {
		DEBUG("weighted");

		graph.forEdges([&](node u, node v, edgeweight w) {
			if (zeta[u] != zeta[v]) {
				commGraph.increaseWeight(zeta[u], zeta[v], w);
				TRACE("increase weight of " , zeta[u] , " and " , zeta[v] , " by " , w);
			}
		});
	} else {
		DEBUG("not weighted");

		graph.forEdges([&](node u, node v) {
			if (zeta[u] != zeta[v]) {
				commGraph.increaseWeight(zeta[u], zeta[v], 1);
				TRACE("increase weight of " , zeta[u] , " and " , zeta[v] , " by 1");
			}
		});
	}

	return commGraph;
}
开发者ID:maxvogel,项目名称:NetworKit-mirror2,代码行数:27,代码来源:GraphClusteringTools.cpp

示例4: resizeFileSystem

bool LibPartedPartitionTable::resizeFileSystem(Report& report, const Partition& partition, qint64 newLength)
{
    bool rval = false;

#if defined LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT
    if (PedGeometry* originalGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), partition.fileSystem().length())) {
        if (PedFileSystem* pedFileSystem = ped_file_system_open(originalGeometry)) {
            if (PedGeometry* resizedGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), newLength)) {
                PedTimer* pedTimer = ped_timer_new(pedTimerHandler, nullptr);
                rval = ped_file_system_resize(pedFileSystem, resizedGeometry, pedTimer);
                ped_timer_destroy(pedTimer);

                if (!rval)
                    report.line() << xi18nc("@info:progress", "Could not resize file system on partition <filename>%1</filename>.", partition.deviceNode());
                ped_geometry_destroy(resizedGeometry);
            } else
                report.line() << xi18nc("@info:progress", "Could not get geometry for resized partition <filename>%1</filename> while trying to resize the file system.", partition.deviceNode());

            ped_file_system_close(pedFileSystem);
        } else
            report.line() << xi18nc("@info:progress", "Could not open partition <filename>%1</filename> while trying to resize the file system.", partition.deviceNode());
        ped_geometry_destroy(originalGeometry);
    } else
        report.line() << xi18nc("@info:progress", "Could not read geometry for partition <filename>%1</filename> while trying to resize the file system.", partition.deviceNode());
#else
    Q_UNUSED(report);
    Q_UNUSED(partition);
    Q_UNUSED(newLength);
#endif

    return rval;
}
开发者ID:KDE,项目名称:kpmcore,代码行数:32,代码来源:libpartedpartitiontable.cpp

示例5: Q_ASSERT

bool LibPartedPartitionTable::updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end)
{
    Q_ASSERT(partition.devicePath() == QString::fromUtf8(pedDevice()->path));

    bool rval = false;

    PedPartition* pedPartition = (partition.roles().has(PartitionRole::Extended))
                                 ? ped_disk_extended_partition(pedDisk())
                                 : ped_disk_get_partition_by_sector(pedDisk(), partition.firstSector());

    if (pedPartition) {
        if (PedGeometry* pedGeometry = ped_geometry_new(pedDevice(), sector_start, sector_end - sector_start + 1)) {
            if (PedConstraint* pedConstraint = ped_constraint_exact(pedGeometry)) {
                if (ped_disk_set_partition_geom(pedDisk(), pedPartition, pedConstraint, sector_start, sector_end))
                    rval = true;
                else
                    report.line() << xi18nc("@info:progress", "Could not set geometry for partition <filename>%1</filename> while trying to resize/move it.", partition.deviceNode());
                ped_constraint_destroy(pedConstraint);
            } else
                report.line() << xi18nc("@info:progress", "Could not get constraint for partition <filename>%1</filename> while trying to resize/move it.", partition.deviceNode());
            ped_geometry_destroy(pedGeometry);
        } else
            report.line() << xi18nc("@info:progress", "Could not get geometry for partition <filename>%1</filename> while trying to resize/move it.", partition.deviceNode());
    } else
        report.line() << xi18nc("@info:progress", "Could not open partition <filename>%1</filename> while trying to resize/move it.", partition.deviceNode());

    return rval;
}
开发者ID:KDE,项目名称:kpmcore,代码行数:28,代码来源:libpartedpartitiontable.cpp

示例6: it_should_calculate_the_original_cost

 bool it_should_calculate_the_original_cost ()
 {
   bool answ;
   unsigned int set_size = 12;
   ElementSet original_set ("", set_size, 100);
   bool * is_fixed = new bool[set_size];
   for (unsigned int i = 0; i < set_size; i++)
     if (i < 5)
       is_fixed[i] = true;
     else
       is_fixed[i] = false;
   Partition part (&original_set, is_fixed);
   delete[] is_fixed;
   ElementSet * fixed_set = part.get_fixed_elm_set ();
   ElementSubset part_subset ("", fixed_set);
   part_subset.add_element (0);
   part_subset.add_element (2);
   part_subset.add_element (4);
   PartitionNode P (&part, &part_subset);
   SubsetSum orig_f (&original_set);
   PartCost P_f (&orig_f, &P);
   ElementSubset X ("", part.get_unfixed_elm_set ());
   X.add_element (0);
   X.add_element (2);
   X.add_element (3);
   ElementSubset * orig_X = P.get_original_subset (&X);
   answ = orig_f.cost (orig_X) == P_f.cost (&X);
   delete orig_X;
   return answ;
 }
开发者ID:msreis,项目名称:featsel,代码行数:30,代码来源:PartCostTest.cpp

示例7: register_boot_file_system

status_t
register_boot_file_system(BootVolume& bootVolume)
{
	Directory* rootDirectory = bootVolume.RootDirectory();
	gRoot->AddLink("boot", rootDirectory);

	Partition *partition;
	status_t status = gRoot->GetPartitionFor(rootDirectory, &partition);
	if (status != B_OK) {
		dprintf("register_boot_file_system(): could not locate boot volume in "
			"root!\n");
		return status;
	}

	gBootVolume.SetInt64(BOOT_VOLUME_PARTITION_OFFSET,
		partition->offset);

	if (bootVolume.IsPackaged()) {
		gBootVolume.SetBool(BOOT_VOLUME_PACKAGED, true);
		PackageVolumeState* state = bootVolume.GetPackageVolumeState();
		if (state->Name() != NULL)
			gBootVolume.AddString(BOOT_VOLUME_PACKAGES_STATE, state->Name());
	}

	Node *device = get_node_from(partition->FD());
	if (device == NULL) {
		dprintf("register_boot_file_system(): could not get boot device!\n");
		return B_ERROR;
	}

	return platform_register_boot_device(device);
}
开发者ID:jessicah,项目名称:haiku-private,代码行数:32,代码来源:vfs.cpp

示例8: add_partitions_for

/*!	Scans the device passed in for partitioning systems. If none are found,
	a partition containing the whole device is created.
	All created partitions are added to the gPartitions list.
*/
status_t
add_partitions_for(int fd, bool mountFileSystems, bool isBootDevice)
{
	TRACE(("add_partitions_for(fd = %d, mountFS = %s)\n", fd,
		mountFileSystems ? "yes" : "no"));

	Partition *partition = new Partition(fd);

	// set some magic/default values
	partition->block_size = 512;
	partition->size = partition->Size();

	// add this partition to the list of partitions, if it contains
	// or might contain a file system
	if ((partition->Scan(mountFileSystems, isBootDevice) == B_OK
			&& partition->IsFileSystem())
		|| (!partition->IsPartitioningSystem() && !mountFileSystems)) {
		gPartitions.Add(partition);
		return B_OK;
	}

	// if not, we no longer need the partition
	delete partition;
	return B_OK;
}
开发者ID:mariuz,项目名称:haiku,代码行数:29,代码来源:partitions.cpp

示例9: qWarning

bool PartitionTable::getUnallocatedRange(const Device& d, PartitionNode& parent, qint64& start, qint64& end)
{
    if (d.type() == Device::Disk_Device) {
        const DiskDevice& device = dynamic_cast<const DiskDevice&>(d);
        if (!parent.isRoot()) {
            Partition* extended = dynamic_cast<Partition*>(&parent);

            if (extended == nullptr) {
                qWarning() << "extended is null. start: " << start << ", end: " << end << ", device: " << device.deviceNode();
                return false;
            }

            // Leave a track (cylinder aligned) or sector alignment sectors (sector based) free at the
            // start for a new partition's metadata
            start += device.partitionTable()->type() == PartitionTable::msdos ? device.sectorsPerTrack() : PartitionAlignment::sectorAlignment(device);

            // .. and also at the end for the metadata for a partition to follow us, if we're not
            // at the end of the extended partition
            if (end < extended->lastSector())
                end -= device.partitionTable()->type() == PartitionTable::msdos ? device.sectorsPerTrack() : PartitionAlignment::sectorAlignment(device);
        }

        return end - start + 1 >= PartitionAlignment::sectorAlignment(device);
    } else if (d.type() == Device::LVM_Device) {
        if (end - start + 1 > 0) {
            return true;
        }
    }
    return false;
}
开发者ID:KDE,项目名称:kpmcore,代码行数:30,代码来源:partitiontable.cpp

示例10: clearChildren

/** @param other Partition to assign from */
Partition& Partition::operator=(const Partition& other)
{
	if (&other == this)
		return *this;

	clearChildren();

	foreach(const Partition* child, other.children())
	{
		Partition* p = new Partition(*child);
		p->setParent(this);
		m_Children.append(p);
	}

	m_Number = other.m_Number;
	m_FileSystem = FileSystemFactory::create(other.fileSystem());
	m_Roles = other.m_Roles;
	m_FirstSector = other.m_FirstSector;
	m_LastSector = other.m_LastSector;
	m_DevicePath = other.m_DevicePath;
	m_PartitionPath = other.m_PartitionPath;
	m_MountPoint = other.m_MountPoint;
	m_AvailableFlags = other.m_AvailableFlags;
	m_ActiveFlags = other.m_ActiveFlags;
	m_IsMounted = other.m_IsMounted;
	m_SectorSize = other.m_SectorSize;
	m_State = other.m_State;

	return *this;
}
开发者ID:Acidburn0zzz,项目名称:partitionmanager,代码行数:31,代码来源:partition.cpp

示例11: Q_ASSERT

void
PartitionPage::onCreateClicked()
{
    QModelIndex index = m_ui->partitionTreeView->currentIndex();
    Q_ASSERT( index.isValid() );

    const PartitionModel* model = static_cast< const PartitionModel* >( index.model() );
    Partition* partition = model->partitionForIndex( index );
    Q_ASSERT( partition );

    if ( !checkCanCreate( model->device() ) )
        return;

    CreatePartitionDialog dlg(
        model->device(),
        partition->parent(),
        nullptr,
        getCurrentUsedMountpoints(),
        this );
    dlg.initFromFreeSpace( partition );
    if ( dlg.exec() == QDialog::Accepted )
    {
        Partition* newPart = dlg.createPartition();
        m_core->createPartition( model->device(), newPart, dlg.newFlags() );
    }
}
开发者ID:calamares,项目名称:calamares,代码行数:26,代码来源:PartitionPage.cpp

示例12: TEST_F

TEST_F(OverlapGTest, testHashingOverlapperForCorrectness) {
	count n = 4;
	Graph G(n);

	Partition zeta(n);
	Partition eta(n);

	zeta.setUpperBound(2);
	zeta[0] = 0;
	zeta[1] = 0;
	zeta[2] = 1;
	zeta[3] = 1;

	eta.setUpperBound(2);
	eta[0] = 0;
	eta[1] = 1;
	eta[2] = 0;
	eta[3] = 1;

	std::vector<Partition> clusterings = {zeta, eta};
	HashingOverlapper overlapper;
	Partition overlap = overlapper.run(G, clusterings);

	INFO("overlap clustering number of clusters: ", overlap.numberOfSubsets());
	INFO("overlap clustering: ", overlap.getVector());
}
开发者ID:maxvogel,项目名称:NetworKit-mirror2,代码行数:26,代码来源:OverlapGTest.cpp

示例13: TeConnResult

AnalyseResult* TeConnectivity::fAnalyse(Object *iObject) {
	TeGraph *lGraph = dynamic_cast<TeGraph*>(iObject);

	TeConnResult* lConnResult = new TeConnResult();

	//----- compute -----
	INFO("Starting analysis of TE connectivity" << endl);
	Ret lRet = gAlgTimer->fStartNewTimer();

	Partition lPartition = fConn(lGraph->fGetGraph());

	if (lRet == OK) {gAlgTimer->fStopTimer();}
	INFO("Ending analysis of TE connectivity" << endl);

	//----- set results -----
	if (cOptPartition == true) {
		lConnResult->fSetPartition(lPartition);
	}
	if (cOptPartitionDet == true) {
		lConnResult->fSetPartitionDet(true);
	}
	lConnResult->fSetConn(lPartition.fGetSetCount() == 1);

	return lConnResult;
}
开发者ID:silverfield,项目名称:ttbl-final,代码行数:25,代码来源:te_connectivity.cpp

示例14: Strategy

void Party::TransformPartitionIntoOrderedListStrategies(DifferentSizePartitions *different_size_partitions) {
    for (DifferentSizePartitions::iterator my_iterator = different_size_partitions->begin();
         my_iterator != different_size_partitions->end(); my_iterator++) {
        SameSizePartitions same_size_partitions = *my_iterator;
        SameSizeStrategies same_size_strategies;
        Strategy *strategy;
        for (SameSizePartitions::iterator same_size_iterator = same_size_partitions.begin();
             same_size_iterator != same_size_partitions.end(); same_size_iterator++) {
            Partition partition = *same_size_iterator;

            strategy = new Strategy(this);
            CandidateListInfo *to_be_find_group;
            for (Partition::iterator group_iterator = partition.begin();
                 group_iterator != partition.end(); group_iterator++) {
                GroupInPartition group_in_partition = *group_iterator;
                to_be_find_group = new CandidateListInfo();
                for (GroupInPartition::iterator my_iterator = group_in_partition.begin();
                     my_iterator != group_in_partition.end(); my_iterator++) {
                    CandidateId candidate_id = *my_iterator;
                    to_be_find_group->candidates_->push_back(candidate_id);
                }
                strategy->candidate_list_info_list_.push_back(GetExactGroupPointer(to_be_find_group));
                delete to_be_find_group;
            }

            same_size_strategies.push_back(*strategy);
            delete strategy;
        }
        strategies_with_different_size_.push_back(same_size_strategies);
    }
}
开发者ID:CheYulin,项目名称:OpenListProportionalElection,代码行数:31,代码来源:open_list_party.cpp

示例15: Q_ASSERT

void
PartitionPage::updateButtons()
{
    bool create = false, edit = false, del = false;

    QModelIndex index = m_ui->partitionTreeView->currentIndex();
    if ( index.isValid() )
    {
        const PartitionModel* model = static_cast< const PartitionModel* >( index.model() );
        Q_ASSERT( model );
        Partition* partition = model->partitionForIndex( index );
        Q_ASSERT( partition );
        bool isFree = KPMHelpers::isPartitionFreeSpace( partition );
        bool isExtended = partition->roles().has( PartitionRole::Extended );

        create = isFree;
        // Keep it simple for now: do not support editing extended partitions as
        // it does not work with our current edit implementation which is
        // actually remove + add. This would not work with extended partitions
        // because they need to be created *before* creating logical partitions
        // inside them, so an edit must be applied without altering the job
        // order.
        edit = !isFree && !isExtended;
        del = !isFree;
    }
    m_ui->createButton->setEnabled( create );
    m_ui->editButton->setEnabled( edit );
    m_ui->deleteButton->setEnabled( del );

    m_ui->newPartitionTableButton->setEnabled( m_ui->deviceComboBox->currentIndex() >= 0 );
}
开发者ID:dgikiller,项目名称:calamares,代码行数:31,代码来源:PartitionPage.cpp


注:本文中的Partition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。