JSObject* IntlCollator::resolvedOptions(ExecState& state) { // 10.3.5 Intl.Collator.prototype.resolvedOptions() (ECMA-402 2.0) // The function returns a new object whose properties and attributes are set as if // constructed by an object literal assigning to each of the following properties the // value of the corresponding internal slot of this Collator object (see 10.4): locale, // usage, sensitivity, ignorePunctuation, collation, as well as those properties shown // in Table 1 whose keys are included in the %Collator%[[relevantExtensionKeys]] // internal slot of the standard built-in object that is the initial value of // Intl.Collator. if (!m_initializedCollator) { initializeCollator(state, jsUndefined(), jsUndefined()); ASSERT(!state.hadException()); } VM& vm = state.vm(); JSObject* options = constructEmptyObject(&state); options->putDirect(vm, vm.propertyNames->locale, jsString(&state, m_locale)); options->putDirect(vm, vm.propertyNames->usage, jsNontrivialString(&state, ASCIILiteral(usageString(m_usage)))); options->putDirect(vm, vm.propertyNames->sensitivity, jsNontrivialString(&state, ASCIILiteral(sensitivityString(m_sensitivity)))); options->putDirect(vm, vm.propertyNames->ignorePunctuation, jsBoolean(m_ignorePunctuation)); options->putDirect(vm, vm.propertyNames->collation, jsString(&state, m_collation)); options->putDirect(vm, vm.propertyNames->numeric, jsBoolean(m_numeric)); return options; }
int main(int argc, const char *argv[]){ clock_t begin = clock(); /*argv[1]: <input file name> argv[2]: <output file name> argv[3]: 1(linear), 2(quadratic), 3(double), 4(perfect) */ if(argc != 4){ std::cout << "ERROR: 3 arguments were not specified" << std::endl; usageString(); exit(0); } std::string inputFileName = argv[1]; std::string outputFileName = argv[2]; std::string methodChoice = argv[3]; std::ifstream in (inputFileName); // input std::ofstream out(outputFileName); if (!in.is_open()) { std::cout << "ERROR: Could not open input file " << inputFileName << std::endl; usageString(); exit(0); } std::ofstream outf (outputFileName); if(!outf.is_open()){ std::cout << "ERROR: Could not open output file " << outputFileName << std::endl; usageString(); exit(0); } METHOD m; switch(stoi(methodChoice)){ case 1: m = LINEAR; break; case 2: m = QUADRATIC; break; case 3: m = DOUBLE; break; case 4: m = PERFECT; break; default: std::cout << "ERROR: Invalid algorithm choice " << methodChoice << std::endl; usageString(); exit(0); } int TOTAL_LINES=0, insertCtr = 0, deleteCtr =0, findCtr= 0; bool doOnce = false; HashTable hash(m, 10007);// Create the HashTable double avgInsert, avgDelete, avgFind, temp; if (in.good()) { clock_t begin = clock(); int numLines; std::string operation; in >> numLines; for (int i = 0; i < numLines; i++) { int numOperations; in >> operation; in >> numOperations; // std::cout << operation << std::endl; for (int j = 0; j < numOperations; i++, j++) { int key, value; in >> key >> value; if (operation == "INSERT") { // std::cout << key << " " << value << std::endl; clock_t insertT = clock(); //std:: cout<< "insertT insert " <<insertT << std::endl; hash.insert(key, value); clock_t endInsertT = clock(); insertCtr++; //std::cout << "endT insert: " << endInsertT << std::endl; temp = double (endInsertT - insertT ) / (CLOCKS_PER_SEC); //std::cout << "Insert: " << temp << std::endl; avgInsert += temp; } else if (operation == "DELETE") { // std::cout << key << std::endl; clock_t removeT = clock(); hash.remove(key, value); clock_t endRemoveT = clock(); temp = double (endRemoveT - removeT) / (CLOCKS_PER_SEC); deleteCtr++; avgDelete += temp; } else if (operation == "FIND") { // std::cout << key << std::endl; clock_t findT = clock(); hash.find(key, value); clock_t endFind = clock(); temp = double (endFind - findT) / (CLOCKS_PER_SEC); findCtr++; avgFind += temp; } else { std::cout << "Invalid operation" << std::endl; return 0; } } } }