是否可以使用PrimeNG的p-multiselect进行like that的操作?
答案 0 :(得分:0)
您可以做的是覆盖PrimeNG风格:
#include <iostream>
#include <fstream>
#include "HeapSort.h"
using namespace std;
int main(int argc, char* argv[]) {
// Input/OutPut files.
string fileInput = argv[1];
string fileOutput1 = argv[2];
string fileOutput2 = argv[3];
ofstream ofs;
//This for loop is used to clear the output files before writting to them.
for (int i = 2; i <= 3; i++){ ofs.open(argv[i], std::ofstream::out | std::ofstream::trunc); ofs.close(); }
//Initializing HeapSort class
HeapSort HS(fileInput, fileOutput1, fileOutput2);
HS.buildHeap();
HS.deleteHeap();
system("PAUSE");
return 0;
}
//HeapSort.h file.
#ifndef HeapSort_H
#define HeapSort_H
#include <iostream>
#include <fstream>
using namespace std;
class HeapSort {
public:
int* heapAry;
int numItems, rootIndex, fatherIndex, leftKidIndex, rightKidIndex, minKidIndex, data;
string input, output1, output2;
//constructor
HeapSort(string filename1, string filename2, string filename3);
int countData();
void buildHeap();
void deleteHeap();
int getRoot();
void replaceRoot();
void bubbleUp(int s);
void bubbleDown(int fatherIndex);
bool isLeaf(int index);
bool isRoot(int index);
int findMinKidIndex(int fatherIndex);
bool isHeapEmpty();
bool isHeapFull();
void printHeap(int s);
void inserOneDataItem(int data);
};//end of HeapSort class
#endif
//HeapSort.cpp file.
#include "HeapSort.h"
#include <iostream>
#include <fstream>
#include<string>
#include <sstream>
#include <algorithm>
using namespace std;
//Used for int conversion to string since library is broken.
namespace patch{
template < typename T > std::string to_string(const T& n){
std::ostringstream stm;
stm << n;
return stm.str();
}
}//End of patch namespace.
//Constructor
HeapSort::HeapSort(string filename1, string filename2, string filename3){
data = countData() + 1;
heapAry = new int[data];
for (int i = 0; i <= data; i++){ heapAry[i] = 0; }
input = filename1;
output1 = filename2;
output2 = filename3;
}//End of cunstructor
int HeapSort::countData(){
ifstream inFile;
inFile.open(input);
int tempInt = 0;
int counter = 0;
while (inFile >> tempInt) { cout << tempInt << "\n"; counter++; }//end of while loop
inFile.close();
return counter;
}//End of countData function
void HeapSort::buildHeap(){
ifstream inFile;
inFile.open(input);
int number = 0;
rootIndex = 1;
while (inFile >> number) {
inserOneDataItem(number);
int kidIndex = heapAry[0];
bubbleUp(kidIndex);
printHeap(1);
}//end of while loop
inFile.close();
}//End of buildHeap function
void HeapSort::deleteHeap(){
ofstream outFile;
outFile.open(output2, ios::app);
while (isHeapEmpty() != true){
int data = getRoot();
if (data != 0){ outFile << " | " << data << " | \n"; }
replaceRoot();
fatherIndex = rootIndex;
bubbleDown(fatherIndex);
printHeap(2);
}//end of while loop
outFile.close();
}//End of deleteHeap function.
int HeapSort::getRoot(){
return heapAry[1];
}//End of getRoot function
void HeapSort::replaceRoot(){
heapAry[1] = heapAry[heapAry[0]];
heapAry[0] = heapAry[0] - 1;
}//End of replaceRoot function
void HeapSort::bubbleUp(int s){
if (isRoot(s)){ return; }//end if clause
else{
fatherIndex = s / 2;
if (heapAry[s] >= heapAry[fatherIndex]){
return;
}//end inner if clause
else{
int temp = heapAry[s];
heapAry[s] = heapAry[fatherIndex];
heapAry[fatherIndex] = temp;
bubbleUp(fatherIndex);
}//end inner else clause
}//end outter else clause
}//End of bubbleUp function
void HeapSort::bubbleDown(int fatherIndex){
if (isLeaf(fatherIndex)){ return; }//end if clause
else{
leftKidIndex = fatherIndex * 2;
rightKidIndex = (fatherIndex * 2) + 1;
minKidIndex = findMinKidIndex(fatherIndex);
if (heapAry[minKidIndex] >= heapAry[fatherIndex]){ return; }//end inner if clause
else{
int temp = heapAry[fatherIndex];
heapAry[fatherIndex] = heapAry[minKidIndex];
heapAry[minKidIndex] = temp;
bubbleDown(minKidIndex);
}//end inner else clause
}//end outter else clause
}//End of bubbleDown function
bool HeapSort::isLeaf(int index){
if (index * 2 > heapAry[0] && (index * 2) + 1 > heapAry[0]){ return true; }//end if clause
else { return false; }//end else clause
}//End of isLeaf function
bool HeapSort::isRoot(int index){
return (index == 1);
}//End of isRoot function
int HeapSort::findMinKidIndex(int fatherIndex){
if (isLeaf(fatherIndex) == true) return fatherIndex;
if ((fatherIndex * 2) + 1 > heapAry[0] && heapAry[(fatherIndex * 2)] < fatherIndex) return fatherIndex * 2;
if ((fatherIndex * 2) + 1 < fatherIndex && (fatherIndex * 2) == 0) return (fatherIndex * 2) + 1;
else{
int s = std::min(heapAry[fatherIndex * 2], heapAry[(fatherIndex * 2) + 1]);
if (s == heapAry[fatherIndex * 2]){ return fatherIndex * 2; }
else { return (fatherIndex * 2) + 1; }
}//end outer else clause
}//End of findMinKidIndex function
bool HeapSort::isHeapEmpty(){ return (heapAry[0] == 0); }//end of isHeapEmpty method
bool HeapSort::isHeapFull(){ return (numItems == data); }//end of isHeapFull method
void HeapSort::printHeap(int s){
ofstream outFile;
outFile.open(output1, ios::app);
if (s == 1){ outFile << "Printing heap after adding one element! \n\n"; }
else if (s == 2){ outFile << "Printing heap after removing one element! \n\n"; }
for (int i = 0; i <= heapAry[0]; i++){
if (heapAry[i] != 0){ outFile << heapAry[i] << " | "; }//end if clause
}//end for loop
outFile << "\n\n\n";
// outFile.close();
}//end of printHeap
void HeapSort::inserOneDataItem(int data){
heapAry[0]++;
heapAry[heapAry[0]] = data;
}//end of inserOneDataItem method
请参阅Plunker
答案 1 :(得分:0)
你也可以像这样在标签上添加样式:
p-multiselect { width: 100%;}
请记住将样式文件作为最后一个css文件加载。