This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package mysort | |
| type Sorter interface { | |
| Len() int | |
| Less(i, j int) bool | |
| Swap(i, j int) | |
| } | |
| func Sort(data Sorter) { | |
| quicksort(0, data.Len()-1, data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bufio" | |
| "bytes" | |
| "flag" | |
| "fmt" | |
| "io" | |
| "os" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| Usage() { | |
| echo "Usage: "$0" directory [maxdepth=1]" | |
| exit 1 | |
| } | |
| SHELL_DIR=$(dirname $0) | |
| if [[ $# -lt 1 || $1 = "-h" || $1 = "--help" ]]; then | |
| Usage | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.apache.pulsar.client.admin.PulsarAdmin; | |
| import org.apache.pulsar.client.admin.PulsarAdminException; | |
| import org.apache.pulsar.client.api.*; | |
| public class CumulativeAck { | |
| public static void main(String[] args) { | |
| final String SERVICE_URL = "pulsar://localhost:6650"; | |
| final String ADMIN_URL = "http://localhost:8080"; | |
| final String TOPIC_NAME = "public/default/FooTest"; | |
| final int NUM_PARTITIONS = 3; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <pulsar/Client.h> | |
| #include <assert.h> | |
| #include <sstream> | |
| using namespace pulsar; | |
| int main(int argc, char* argv[]) { | |
| Client client("pulsar://localhost:6650"); | |
| ProducerConfiguration producerConfig; | |
| producerConfig.setSendTimeout(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <vector> | |
| using std::cout; | |
| using std::endl; | |
| // https://github.com/open-source-parsers/jsoncpp | |
| #include <json/json.h> | |
| static std::string json_data = R"(// Configuration options | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #include <functional> | |
| #include <iostream> | |
| #include <vector> | |
| struct ListNode { | |
| int val; | |
| ListNode* next = nullptr; | |
| ListNode(int val_ = 0) : val(val_) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #if __cplusplus < 201402L | |
| #error "C++ standard must be at least 14" | |
| #endif | |
| #include <iostream> | |
| #include <vector> | |
| template <typename T> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <gtest/gtest.h> | |
| #include <pulsar/Client.h> | |
| #include <fstream> | |
| using namespace pulsar; | |
| static std::string kLogPath = "custom_logger.txt"; | |
| static std::string kPrefix = "hello world"; | |
| class MyLogger : public Logger { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // g++ ObjectPool.cc -std=c++14 -pthread -O2 | |
| #include "ObjectPool.h" // https://github.com/apache/pulsar/tree/master/pulsar-client-cpp/lib/ObjectPool.h | |
| #include <chrono> | |
| #include <iostream> | |
| #include <thread> | |
| #include <vector> | |
| using namespace std; | |
| inline auto now() { return std::chrono::high_resolution_clock::now(); } |
OlderNewer