Dataset Preview
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
Could not read the parquet files: Parquet file size is 0 bytes
Error code: FileSystemError
Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
blob_id
string | directory_id
string | path
string | content_id
string | detected_licenses
sequence | license_type
string | repo_name
string | snapshot_id
string | revision_id
string | branch_name
string | visit_date
int64 | revision_date
int64 | committer_date
int64 | github_id
int64 | star_events_count
int64 | fork_events_count
int64 | gha_license_id
string | gha_event_created_at
int64 | gha_created_at
int64 | gha_language
string | src_encoding
string | language
string | is_vendor
bool | is_generated
bool | length_bytes
int64 | extension
string | filename
string | text
string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
48601d850ff7609e4718c4424ee7b382bfad8302
|
7a1b68164eeb0f1863d63f9aeff4b8d82b9c6467
|
/SmartHomeBoard/Contactor.h
|
751ccfb00c05e742c2fc2e22e8693dc61f735b04
|
[] |
no_license
|
igorgsh/SmartHouse
|
42034fa0859ef51b3b8945135e5d3aaa9b6a08b6
|
1a3742a019e486508793ebe22fa4f3bfaa9fd808
|
refs/heads/master
| 1,676,675,467,749,322,000
| 1,676,483,942,000,000,000
| 1,676,483,942,000,000,000
| 78,925,305
| 1
| 1
| null | 1,640,463,027,000,000,000
| 1,484,379,489,000,000,000
|
C++
|
UTF-8
|
C++
| false
| false
| 862
|
h
|
Contactor.h
|
// Contactor.h
#ifndef _CONTACTOR_h
#define _CONTACTOR_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
#include "Unit.h"
#define CONTACTOR_SWITCHED_TIME 100
class Contactor:public Unit
{
public:
bool lhOn;
void InitUnit(bool isParent);
void UnitLoop(unsigned long timePeriod, bool isParent, bool val);
void FinalInitUnit(bool isParent);
void ProcessUnit(ActionType event);
bool Compare(const Unit* u);
byte UnitStoredSize() { return 7; }
void ReadFromEEPROM(uint16_t addr);
void WriteToEEPROM(uint16_t addr);
void ConfigField(const JsonObject& jsonList);
void const print(const char* header, DebugLevel level);
private:
unsigned long startContact=0;
byte prevValue;
void HandleContactor(unsigned long timePeriod, bool isDirect, bool v);
void HandleFinish(int newStatus);
};
#endif
|
d5988c71dca03ea4ace05b00e1b68d24dadffdf1
|
2ee7195d71993838829e06f26347f76a2433931b
|
/QUANTAXIS_Trade/PYCTP/PyCTP_wrap.h
|
b256b78a62dc9c6b655ccccf5df8839b934e6c7c
|
[
"MIT"
] |
permissive
|
imgreenbird/QUANTAXIS
|
0a056de2c3961f5d0b7d0e17782f34b25593e5fb
|
88eac434135a92cd64bd035cd844b34020729747
|
refs/heads/master
| 1,584,973,643,003,742,000
| 1,532,049,927,000,000,000
| 1,532,049,927,000,000,000
| 141,676,903
| 3
| 0
|
MIT
| 1,532,070,669,000,000,000
| 1,532,070,669,000,000,000
| null |
UTF-8
|
C++
| false
| false
| 20,944
|
h
|
PyCTP_wrap.h
|
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.12
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
* changes to this file unless you know what you are doing--modify the SWIG
* interface file instead.
* ----------------------------------------------------------------------------- */
#ifndef SWIG_PyCTP_WRAP_H_
#define SWIG_PyCTP_WRAP_H_
#include <map>
#include <string>
class SwigDirector_CThostFtdcMdSpi : public CThostFtdcMdSpi, public Swig::Director {
public:
SwigDirector_CThostFtdcMdSpi(PyObject *self);
virtual void OnFrontConnected();
virtual void OnFrontDisconnected(int nReason);
virtual void OnHeartBeatWarning(int nTimeLapse);
virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData);
virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp);
/* Internal director utilities */
public:
bool swig_get_inner(const char *swig_protected_method_name) const {
std::map<std::string, bool>::const_iterator iv = swig_inner.find(swig_protected_method_name);
return (iv != swig_inner.end() ? iv->second : false);
}
void swig_set_inner(const char *swig_protected_method_name, bool swig_val) const {
swig_inner[swig_protected_method_name] = swig_val;
}
private:
mutable std::map<std::string, bool> swig_inner;
#if defined(SWIG_PYTHON_DIRECTOR_VTABLE)
/* VTable implementation */
PyObject *swig_get_method(size_t method_index, const char *method_name) const {
PyObject *method = vtable[method_index];
if (!method) {
swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);
method = PyObject_GetAttr(swig_get_self(), name);
if (!method) {
std::string msg = "Method in class CThostFtdcMdSpi doesn't exist, undefined ";
msg += method_name;
Swig::DirectorMethodException::raise(msg.c_str());
}
vtable[method_index] = method;
}
return method;
}
private:
mutable swig::SwigVar_PyObject vtable[12];
#endif
};
class SwigDirector_CThostFtdcTraderSpi : public CThostFtdcTraderSpi, public Swig::Director {
public:
SwigDirector_CThostFtdcTraderSpi(PyObject *self);
virtual void OnFrontConnected();
virtual void OnFrontDisconnected(int nReason);
virtual void OnHeartBeatWarning(int nTimeLapse);
virtual void OnRspAuthenticate(CThostFtdcRspAuthenticateField *pRspAuthenticateField, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspUserPasswordUpdate(CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspTradingAccountPasswordUpdate(CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspOrderInsert(CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspParkedOrderInsert(CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspOrderAction(CThostFtdcInputOrderActionField *pInputOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQueryMaxOrderVolume(CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspSettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspRemoveParkedOrder(CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspRemoveParkedOrderAction(CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspExecOrderInsert(CThostFtdcInputExecOrderField *pInputExecOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspExecOrderAction(CThostFtdcInputExecOrderActionField *pInputExecOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspForQuoteInsert(CThostFtdcInputForQuoteField *pInputForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQuoteInsert(CThostFtdcInputQuoteField *pInputQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQuoteAction(CThostFtdcInputQuoteActionField *pInputQuoteAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspBatchOrderAction(CThostFtdcInputBatchOrderActionField *pInputBatchOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspOptionSelfCloseInsert(CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspOptionSelfCloseAction(CThostFtdcInputOptionSelfCloseActionField *pInputOptionSelfCloseAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspCombActionInsert(CThostFtdcInputCombActionField *pInputCombAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryOrder(CThostFtdcOrderField *pOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryTrade(CThostFtdcTradeField *pTrade, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryInvestorPosition(CThostFtdcInvestorPositionField *pInvestorPosition, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryTradingAccount(CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryInvestor(CThostFtdcInvestorField *pInvestor, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryTradingCode(CThostFtdcTradingCodeField *pTradingCode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryInstrumentMarginRate(CThostFtdcInstrumentMarginRateField *pInstrumentMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryInstrumentCommissionRate(CThostFtdcInstrumentCommissionRateField *pInstrumentCommissionRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryExchange(CThostFtdcExchangeField *pExchange, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryProduct(CThostFtdcProductField *pProduct, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryInstrument(CThostFtdcInstrumentField *pInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQrySettlementInfo(CThostFtdcSettlementInfoField *pSettlementInfo, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryTransferBank(CThostFtdcTransferBankField *pTransferBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryInvestorPositionDetail(CThostFtdcInvestorPositionDetailField *pInvestorPositionDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryNotice(CThostFtdcNoticeField *pNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQrySettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryInvestorPositionCombineDetail(CThostFtdcInvestorPositionCombineDetailField *pInvestorPositionCombineDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryCFMMCTradingAccountKey(CThostFtdcCFMMCTradingAccountKeyField *pCFMMCTradingAccountKey, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryEWarrantOffset(CThostFtdcEWarrantOffsetField *pEWarrantOffset, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryInvestorProductGroupMargin(CThostFtdcInvestorProductGroupMarginField *pInvestorProductGroupMargin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryExchangeMarginRate(CThostFtdcExchangeMarginRateField *pExchangeMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryExchangeMarginRateAdjust(CThostFtdcExchangeMarginRateAdjustField *pExchangeMarginRateAdjust, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryExchangeRate(CThostFtdcExchangeRateField *pExchangeRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQrySecAgentACIDMap(CThostFtdcSecAgentACIDMapField *pSecAgentACIDMap, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryProductExchRate(CThostFtdcProductExchRateField *pProductExchRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryProductGroup(CThostFtdcProductGroupField *pProductGroup, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryMMInstrumentCommissionRate(CThostFtdcMMInstrumentCommissionRateField *pMMInstrumentCommissionRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryMMOptionInstrCommRate(CThostFtdcMMOptionInstrCommRateField *pMMOptionInstrCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryInstrumentOrderCommRate(CThostFtdcInstrumentOrderCommRateField *pInstrumentOrderCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQrySecAgentTradingAccount(CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQrySecAgentCheckMode(CThostFtdcSecAgentCheckModeField *pSecAgentCheckMode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryOptionInstrTradeCost(CThostFtdcOptionInstrTradeCostField *pOptionInstrTradeCost, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryOptionInstrCommRate(CThostFtdcOptionInstrCommRateField *pOptionInstrCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryExecOrder(CThostFtdcExecOrderField *pExecOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryForQuote(CThostFtdcForQuoteField *pForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryQuote(CThostFtdcQuoteField *pQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryOptionSelfClose(CThostFtdcOptionSelfCloseField *pOptionSelfClose, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryInvestUnit(CThostFtdcInvestUnitField *pInvestUnit, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryCombInstrumentGuard(CThostFtdcCombInstrumentGuardField *pCombInstrumentGuard, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryCombAction(CThostFtdcCombActionField *pCombAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryTransferSerial(CThostFtdcTransferSerialField *pTransferSerial, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryAccountregister(CThostFtdcAccountregisterField *pAccountregister, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRtnOrder(CThostFtdcOrderField *pOrder);
virtual void OnRtnTrade(CThostFtdcTradeField *pTrade);
virtual void OnErrRtnOrderInsert(CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo);
virtual void OnErrRtnOrderAction(CThostFtdcOrderActionField *pOrderAction, CThostFtdcRspInfoField *pRspInfo);
virtual void OnRtnInstrumentStatus(CThostFtdcInstrumentStatusField *pInstrumentStatus);
virtual void OnRtnBulletin(CThostFtdcBulletinField *pBulletin);
virtual void OnRtnTradingNotice(CThostFtdcTradingNoticeInfoField *pTradingNoticeInfo);
virtual void OnRtnErrorConditionalOrder(CThostFtdcErrorConditionalOrderField *pErrorConditionalOrder);
virtual void OnRtnExecOrder(CThostFtdcExecOrderField *pExecOrder);
virtual void OnErrRtnExecOrderInsert(CThostFtdcInputExecOrderField *pInputExecOrder, CThostFtdcRspInfoField *pRspInfo);
virtual void OnErrRtnExecOrderAction(CThostFtdcExecOrderActionField *pExecOrderAction, CThostFtdcRspInfoField *pRspInfo);
virtual void OnErrRtnForQuoteInsert(CThostFtdcInputForQuoteField *pInputForQuote, CThostFtdcRspInfoField *pRspInfo);
virtual void OnRtnQuote(CThostFtdcQuoteField *pQuote);
virtual void OnErrRtnQuoteInsert(CThostFtdcInputQuoteField *pInputQuote, CThostFtdcRspInfoField *pRspInfo);
virtual void OnErrRtnQuoteAction(CThostFtdcQuoteActionField *pQuoteAction, CThostFtdcRspInfoField *pRspInfo);
virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp);
virtual void OnRtnCFMMCTradingAccountToken(CThostFtdcCFMMCTradingAccountTokenField *pCFMMCTradingAccountToken);
virtual void OnErrRtnBatchOrderAction(CThostFtdcBatchOrderActionField *pBatchOrderAction, CThostFtdcRspInfoField *pRspInfo);
virtual void OnRtnOptionSelfClose(CThostFtdcOptionSelfCloseField *pOptionSelfClose);
virtual void OnErrRtnOptionSelfCloseInsert(CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose, CThostFtdcRspInfoField *pRspInfo);
virtual void OnErrRtnOptionSelfCloseAction(CThostFtdcOptionSelfCloseActionField *pOptionSelfCloseAction, CThostFtdcRspInfoField *pRspInfo);
virtual void OnRtnCombAction(CThostFtdcCombActionField *pCombAction);
virtual void OnErrRtnCombActionInsert(CThostFtdcInputCombActionField *pInputCombAction, CThostFtdcRspInfoField *pRspInfo);
virtual void OnRspQryContractBank(CThostFtdcContractBankField *pContractBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryParkedOrder(CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryTradingNotice(CThostFtdcTradingNoticeField *pTradingNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryBrokerTradingParams(CThostFtdcBrokerTradingParamsField *pBrokerTradingParams, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQryBrokerTradingAlgos(CThostFtdcBrokerTradingAlgosField *pBrokerTradingAlgos, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQueryCFMMCTradingAccountToken(CThostFtdcQueryCFMMCTradingAccountTokenField *pQueryCFMMCTradingAccountToken, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRtnFromBankToFutureByBank(CThostFtdcRspTransferField *pRspTransfer);
virtual void OnRtnFromFutureToBankByBank(CThostFtdcRspTransferField *pRspTransfer);
virtual void OnRtnRepealFromBankToFutureByBank(CThostFtdcRspRepealField *pRspRepeal);
virtual void OnRtnRepealFromFutureToBankByBank(CThostFtdcRspRepealField *pRspRepeal);
virtual void OnRtnFromBankToFutureByFuture(CThostFtdcRspTransferField *pRspTransfer);
virtual void OnRtnFromFutureToBankByFuture(CThostFtdcRspTransferField *pRspTransfer);
virtual void OnRtnRepealFromBankToFutureByFutureManual(CThostFtdcRspRepealField *pRspRepeal);
virtual void OnRtnRepealFromFutureToBankByFutureManual(CThostFtdcRspRepealField *pRspRepeal);
virtual void OnRtnQueryBankBalanceByFuture(CThostFtdcNotifyQueryAccountField *pNotifyQueryAccount);
virtual void OnErrRtnBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo);
virtual void OnErrRtnFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo);
virtual void OnErrRtnRepealBankToFutureByFutureManual(CThostFtdcReqRepealField *pReqRepeal, CThostFtdcRspInfoField *pRspInfo);
virtual void OnErrRtnRepealFutureToBankByFutureManual(CThostFtdcReqRepealField *pReqRepeal, CThostFtdcRspInfoField *pRspInfo);
virtual void OnErrRtnQueryBankBalanceByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, CThostFtdcRspInfoField *pRspInfo);
virtual void OnRtnRepealFromBankToFutureByFuture(CThostFtdcRspRepealField *pRspRepeal);
virtual void OnRtnRepealFromFutureToBankByFuture(CThostFtdcRspRepealField *pRspRepeal);
virtual void OnRspFromBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspFromFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRspQueryBankAccountMoneyByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
virtual void OnRtnOpenAccountByBank(CThostFtdcOpenAccountField *pOpenAccount);
virtual void OnRtnCancelAccountByBank(CThostFtdcCancelAccountField *pCancelAccount);
virtual void OnRtnChangeAccountByBank(CThostFtdcChangeAccountField *pChangeAccount);
/* Internal director utilities */
public:
bool swig_get_inner(const char *swig_protected_method_name) const {
std::map<std::string, bool>::const_iterator iv = swig_inner.find(swig_protected_method_name);
return (iv != swig_inner.end() ? iv->second : false);
}
void swig_set_inner(const char *swig_protected_method_name, bool swig_val) const {
swig_inner[swig_protected_method_name] = swig_val;
}
private:
mutable std::map<std::string, bool> swig_inner;
#if defined(SWIG_PYTHON_DIRECTOR_VTABLE)
/* VTable implementation */
PyObject *swig_get_method(size_t method_index, const char *method_name) const {
PyObject *method = vtable[method_index];
if (!method) {
swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);
method = PyObject_GetAttr(swig_get_self(), name);
if (!method) {
std::string msg = "Method in class CThostFtdcTraderSpi doesn't exist, undefined ";
msg += method_name;
Swig::DirectorMethodException::raise(msg.c_str());
}
vtable[method_index] = method;
}
return method;
}
private:
mutable swig::SwigVar_PyObject vtable[121];
#endif
};
#endif
|
5f3e9357dda9428e788c286370b0da2aedeecb5c
|
52fbd6e9b404487a794d06230b6ff42750c2490d
|
/Source/Foundation/Controller/Elixir-UI.hpp
|
81a3868924baf6f2d754b96e361238441785daa0
|
[] |
no_license
|
D4mo/Elixir
|
23d9dbc82f8dae12ae9332bd65582216934aeda1
|
b01404c79306a73d370a6c496c446895df5f1c74
|
refs/heads/master
| 1,669,785,332,053,787,000
| 1,597,688,948,000,000,000
| 1,597,688,948,000,000,000
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,275
|
hpp
|
Elixir-UI.hpp
|
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Copyright (C) 2016-2020 by Agustin Alvarez. All rights reserved.
//
// This work is licensed under the terms of the Apache License, Version 2.0.
//
// See <https://opensource.org/licenses/Apache-2.0>.
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#pragma once
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// [ HEADER ]
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#include "Foundation/Core/Elixir-Character.hpp"
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// [ CODE ]
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
namespace Elixir::Controller::UI
{
// (Missing Documentation)
void On_Module_Load(HANDLE File);
// (Missing Documentation)
void On_Module_Save(HANDLE File);
// (Missing Documentation)
bool On_Module_Tick(uint32_t Time);
}
|
3b6f55334356726af32c9bded7cb95444d47087f
|
e5a761290c75ae48cf47442f3b87db190cd01f8f
|
/raytracer/raytracer/primitives/sphere-primitive.cpp
|
31b75ef0081a40a5789951ab531119784c5d6db0
|
[] |
no_license
|
thomasvangoidsenhoven/Raytracer-3D-Cplus
|
d5dd0950cec6cc9ffabf527732f506af2973704d
|
c7741ae3d02cd1cc5d35e97613252d580724d25a
|
refs/heads/master
| 1,588,189,630,530,740,000
| 1,547,028,599,000,000,000
| 1,547,028,599,000,000,000
| 176,365,933
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,011
|
cpp
|
sphere-primitive.cpp
|
#include "primitives/sphere-primitive.h"
#include "util/misc.h"
#include "math/coordinate-systems.h"
#include "math/quadratic_equation.h"
#include "performance/performance.h"
#include <assert.h>
using namespace raytracer;
using namespace raytracer::primitives;
using namespace math;
namespace
{
class SphereImplementation : public raytracer::primitives::_private_::PrimitiveImplementation
{
public:
bool find_first_positive_hit(const Ray& ray, Hit* hit) const override
{
assert(hit != nullptr);
double a = ray.direction.dot(ray.direction);
double b = 2 * ray.direction.dot(ray.origin - Point3D(0, 0, 0));
double c = (ray.origin - Point3D()).norm_sqr() - 1;
QuadraticEquation qeq(a, b, c);
if (qeq.has_solutions())
{
double t1 = qeq.x1();
double t2 = qeq.x2();
double t;
// Find smallest positive t-value
if (smallest_greater_than_zero(t1, t2, &t))
{
// Check that our new t is better than the pre-existing t
if (t < hit->t)
{
initialize_hit(hit, ray, t);
return true;
}
}
}
return false;
}
std::vector<std::shared_ptr<Hit>> find_all_hits(const Ray& ray) const override
{
// See sphere formulae
double a = ray.direction.dot(ray.direction);
double b = 2 * ray.direction.dot(ray.origin - Point3D());
double c = (ray.origin - Point3D()).norm_sqr() - 1;
QuadraticEquation qeq(a, b, c);
// If the ray hits the sphere, the quadratic equation will have solutions
if (qeq.has_solutions())
{
// Quadratic equation has solutions: there are two intersections
double t1 = qeq.x1();
double t2 = qeq.x2();
// We want t1 < t2, swap them if necessary
sort(t1, t2);
// Sanity check (only performed in debug builds)
assert(t1 <= t2);
// Allocate vector on stack
std::vector<std::shared_ptr<Hit>> hits;
// Allocate two Hit objects on heap and store address in shared pointers
auto hit1 = std::make_shared<Hit>();
auto hit2 = std::make_shared<Hit>();
// Initialize both hits
initialize_hit(hit1.get(), ray, t1);
initialize_hit(hit2.get(), ray, t2);
// Put hits in vector
hits.push_back(hit1);
hits.push_back(hit2);
// Return hit list
return hits;
}
else
{
// No intersections to be found
return std::vector<std::shared_ptr<Hit>>();
}
}
math::Box bounding_box() const override
{
// Create a [-1, 1] x [-1, 1] x [-1, 1] box.
auto range = interval(-1.0, 1.0);
return Box(range, range, range);
}
private:
Point2D compute_uv_from_xyz(const Point3D& p) const
{
Cartesian3D cartesian{ p.x(), p.y(), p.z() };
Spherical spherical = convert_coordinates<Spherical>(cartesian);
double u = fmod(Interval<Angle>(-180_degrees, 180_degrees).to_relative(spherical.azimuth) + 0.5, 1.0);
double v = Interval<Angle>(90_degrees, -90_degrees).to_relative(spherical.elevation);
assert(0 <= u);
assert(u <= 1);
assert(0 <= v);
assert(v <= 1);
return Point2D(u, v);
}
void initialize_hit(Hit* hit, const Ray& ray, double t) const
{
// Update Hit object
hit->t = t;
hit->position = ray.at(t);
hit->local_position.xyz = hit->position;
hit->local_position.uv = compute_uv_from_xyz(hit->position);
hit->normal = compute_normal_at(ray, hit->position);
assert(is_on_sphere(hit->position));
}
Vector3D compute_normal_at(const Ray& ray, const Point3D& position) const
{
assert(is_on_sphere(position));
// Compute normal on sphere at position. Always points outwards
Vector3D outward_normal = position - Point3D();
// Make normal points towards the ray's origin
Vector3D normal = ray.direction.dot(outward_normal) < 0 ? outward_normal : -outward_normal;
return normal;
}
bool is_on_sphere(const Point3D& p) const
{
return distance(Point3D(0, 0, 0), p) == approx(1.0);
}
};
}
Primitive raytracer::primitives::sphere()
{
return Primitive(std::make_shared<SphereImplementation>());
}
|
5cf985ce0e4904d1cc0a2c2463bf4c627d640f74
|
3102ded71d5329cf766f17d86c2020d3cfe1bfa2
|
/automotive/maliput/api/lane.h
|
f82377de1ac1785379335f9c42ac0bb15293681e
|
[
"BSD-3-Clause"
] |
permissive
|
mposa/drake
|
14af4ddfbd6a791f2aea7b85ad2b60a7c84f76b8
|
6a9a53da41c35903c24cdf4b29e5e99f71e0a1e9
|
refs/heads/master
| 1,651,426,087,688,899,000
| 1,565,619,316,000,000,000
| 1,565,619,316,000,000,000
| 16,321,603
| 1
| 2
|
NOASSERTION
| 1,647,110,755,000,000,000
| 1,390,934,551,000,000,000
|
C++
|
UTF-8
|
C++
| false
| false
| 13,346
|
h
|
lane.h
|
#pragma once
#include <memory>
#include <string>
#include "drake/automotive/deprecated.h"
#include "drake/automotive/maliput/api/lane_data.h"
#include "drake/automotive/maliput/api/type_specific_identifier.h"
#include "drake/common/autodiff.h"
#include "drake/common/drake_copyable.h"
#include "drake/common/drake_optional.h"
#include "drake/common/symbolic.h"
namespace drake {
namespace maliput {
namespace api {
class BranchPoint;
class Segment;
class LaneEndSet;
/// Persistent identifier for a Lane element.
using LaneId = TypeSpecificIdentifier<class Lane>;
/// A Lane represents a lane of travel in a road network. A Lane defines
/// a curvilinear coordinate system covering the road surface, with a
/// longitudinal 's' coordinate that expresses the arc-length along a
/// central reference curve. The reference curve nominally represents
/// an ideal travel trajectory along the Lane.
///
/// Lanes are grouped by Segment. All Lanes belonging to a Segment
/// represent the same road surface, but with different coordinate
/// parameterizations (e.g., each Lane has its own reference curve).
class DRAKE_DEPRECATED_AUTOMOTIVE
Lane {
public:
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(Lane)
virtual ~Lane() = default;
/// Returns the persistent identifier.
LaneId id() const { return do_id(); }
/// Returns the Segment to which this Lane belongs.
const Segment* segment() const { return do_segment(); }
/// Returns the index of this Lane within the Segment which owns it.
int index() const { return do_index(); }
/// Returns a pointer to the adjacent Lane to the left of this Lane.
///
/// Left is considered the +r direction with regards to the (s,r,h) frame,
/// e.g., "to the left along the +s direction".
///
/// @returns nullptr iff parent Segment has no Lane to the left.
const Lane* to_left() const { return do_to_left(); }
/// Returns a pointer to the adjacent Lane to the right of this Lane.
///
/// Right is considered the -r direction with regards to the (s,r,h) frame,
/// e.g., "to the right along the +s direction".
///
/// @returns nullptr iff parent Segment has no Lane to the right.
const Lane* to_right() const { return do_to_right(); }
/// Returns the arc-length of the Lane along its reference curve.
///
/// The value of length() is also the maximum s-coordinate for this Lane;
/// i.e., the domain of s is [0, length()].
double length() const { return do_length(); }
/// Returns the nominal lateral (r) bounds for the lane as a function of s.
///
/// These are the lateral bounds for a position that is considered to be
/// "staying in the lane".
RBounds lane_bounds(double s) const { return do_lane_bounds(s); }
/// Returns the driveable lateral (r) bounds of the lane as a function of s.
///
/// These are the lateral bounds for a position that is considered to be
/// "on pavement", reflecting the physical extent of the paved surface of
/// the lane's segment.
RBounds driveable_bounds(double s) const { return do_driveable_bounds(s); }
/// Returns the elevation (`h`) bounds of the lane as a function of `(s, r)`.
///
/// These are the elevation bounds for a position that is considered to be
/// within the volume modelled by the RoadGeometry.
HBounds elevation_bounds(double s, double r) const {
return do_elevation_bounds(s, r); }
/// Returns the GeoPosition corresponding to the given LanePosition.
///
/// @pre The s component of @p lane_pos must be in domain [0, Lane::length()].
/// @pre The r component of @p lane_pos must be in domain [Rmin, Rmax]
/// derived from Lane::driveable_bounds().
//
// TODO(jadecastro): Generalize `Lane::ToGeoPosition` (and possibly others)
// with another member function `Lane::ToGeoPositionT<T>()`.
GeoPosition ToGeoPosition(const LanePosition& lane_pos) const {
return DoToGeoPosition(lane_pos);
}
// TODO(jadecastro): Apply this implementation in all the subclasses of
// `api::Lane`.
/// Generalization of ToGeoPosition to arbitrary scalar types, where the
/// structures `LanePositionT<T>` and `GeoPositionT<T>` are used in place of
/// `LanePosition` and `GeoPosition`, respectively.
///
/// When the arguments are of type AutoDiffXd, the return value is a
/// GeoPositionT<AutoDiffXd> containing the same partial derivatives as those
/// appearing in lane_pos. The provided lane_pos must be internally
/// consistent; the s, r, and h variables must have derivatives of equal size,
/// and where the i-th derivative of one variable is taken with respect to the
/// same quantity as the i-th derviative of another variable.
///
/// Instantiated templates for the following kinds of T's are provided:
///
/// - double
/// - drake::AutoDiffXd
/// - drake::symbolic::Expression
///
/// They are already available to link against in the containing library.
///
/// @note This is an experimental API that is not necessarily implemented in
/// all back-end implementations.
template <typename T>
GeoPositionT<T> ToGeoPositionT(const LanePositionT<T>& lane_pos) const;
/// Determines the LanePosition corresponding to GeoPosition @p geo_pos.
///
/// The return value is the LanePosition of the point within the Lane's
/// driveable-bounds which is closest to @p geo_pos (as measured by the
/// Cartesian metric in the world frame). If @p nearest_point is non-null,
/// then it will be populated with the GeoPosition of that nearest point. If
/// @p distance is non-null, then it will be populated with the Cartesian
/// distance from @p geo_pos to that nearest point.
///
/// This method guarantees that its result satisfies the condition that
/// `ToGeoPosition(result)` is within `linear_tolerance()` of
/// `*nearest_position`.
LanePosition ToLanePosition(const GeoPosition& geo_pos,
GeoPosition* nearest_point,
double* distance) const {
return DoToLanePosition(geo_pos, nearest_point, distance);
}
/// Generalization of ToLanePosition to arbitrary scalar types, where the
/// structures `LanePositionT<T>` and `GeoPositionT<T>` are used in place of
/// `LanePosition` and `GeoPosition`, respectively.
///
/// When the arguments are of type AutoDiffXd, the return value is a
/// LanePositionT<AutoDiffXd> containing the same partial derivatives as those
/// appearing in geo_pos. The provided geo_pos must be internally consistent;
/// the x, y, and z variables must have derivatives of equal size, and where
/// the i-th derivative of one variable is taken with respect to the same
/// quantity as the i-th derviative of another variable. If either @p
/// nearest_point or @p distance are non-null, they will also contain @p
/// geo_pos's partial derivatives.
///
/// Instantiated templates for the following kinds of T's are provided:
///
/// - double
/// - drake::AutoDiffXd
/// - drake::symbolic::Expression
///
/// They are already available to link against in the containing library.
///
/// @note This is an experimental API that is not necessarily implemented in
/// all back-end implementations.
//
// TODO(jadecastro): Consider having the client enforce the geo_pos AutoDiffXd
// coherency contract rather than api::Lane. Reevaluate this once an AutoDiff
// consumer for api::ToLanePositionT() exists.
// TODO(jadecastro): Apply this implementation in all the subclasses of
// `api::Lane`.
template <typename T>
LanePositionT<T> ToLanePositionT(const GeoPositionT<T>& geo_pos,
GeoPositionT<T>* nearest_point,
T* distance) const;
// TODO(maddog@tri.global) Method to convert LanePosition to that of
// another Lane. (Should assert that both
// lanes belong to same Segment.) It should look
// something like this:
// LanePosition ToOtherLane(const LanePosition& in_this_lane,
// const Lane* other_lane) const;
/// Returns the rotation which expresses the orientation of the
/// `Lane`-frame basis at @p lane_pos with respect to the
/// world frame basis.
Rotation GetOrientation(const LanePosition& lane_pos) const {
return DoGetOrientation(lane_pos);
}
/// Computes derivatives of LanePosition given a velocity vector @p velocity.
/// @p velocity is a isometric velocity vector oriented in the `Lane`-frame
/// at @p position.
///
/// @returns `Lane`-frame derivatives packed into a LanePosition struct.
LanePosition EvalMotionDerivatives(const LanePosition& position,
const IsoLaneVelocity& velocity) const {
return DoEvalMotionDerivatives(position, velocity);
}
// TODO(maddog@tri.global) Design/implement this.
// void EvalSurfaceDerivatives(...) const { return do_(); }
/// Returns the lane's BranchPoint for the end specified by @p which_end.
const BranchPoint* GetBranchPoint(const LaneEnd::Which which_end) const {
return DoGetBranchPoint(which_end);
}
/// Returns the set of LaneEnd's which connect with this lane on the
/// same side of the BranchPoint at @p which_end. At a minimum,
/// this set will include this Lane.
const LaneEndSet* GetConfluentBranches(
const LaneEnd::Which which_end) const {
return DoGetConfluentBranches(which_end);
}
/// Returns the set of LaneEnd's which continue onward from this lane at the
/// BranchPoint at @p which_end.
const LaneEndSet* GetOngoingBranches(
const LaneEnd::Which which_end) const {
return DoGetOngoingBranches(which_end);
}
/// Returns the default ongoing LaneEnd connected at @p which_end,
/// or nullopt if no default branch has been established at @p which_end.
optional<LaneEnd> GetDefaultBranch(
const LaneEnd::Which which_end) const {
return DoGetDefaultBranch(which_end);
}
protected:
Lane() = default;
private:
/// @name NVI implementations of the public methods.
/// These must satisfy the constraints/invariants of the
/// corresponding public methods.
///@{
virtual LaneId do_id() const = 0;
virtual const Segment* do_segment() const = 0;
virtual int do_index() const = 0;
virtual const Lane* do_to_left() const = 0;
virtual const Lane* do_to_right() const = 0;
virtual double do_length() const = 0;
virtual RBounds do_lane_bounds(double s) const = 0;
virtual RBounds do_driveable_bounds(double s) const = 0;
virtual HBounds do_elevation_bounds(double s, double r) const = 0;
virtual GeoPosition DoToGeoPosition(const LanePosition& lane_pos) const = 0;
virtual LanePosition DoToLanePosition(
const GeoPosition& geo_pos,
GeoPosition* nearest_point,
double* distance) const = 0;
virtual Rotation DoGetOrientation(const LanePosition& lane_pos) const = 0;
virtual LanePosition DoEvalMotionDerivatives(
const LanePosition& position, const IsoLaneVelocity& velocity) const = 0;
virtual const BranchPoint* DoGetBranchPoint(
const LaneEnd::Which which_end) const = 0;
virtual const LaneEndSet* DoGetConfluentBranches(
const LaneEnd::Which which_end) const = 0;
virtual const LaneEndSet* DoGetOngoingBranches(
const LaneEnd::Which which_end) const = 0;
virtual optional<LaneEnd> DoGetDefaultBranch(
const LaneEnd::Which which_end) const = 0;
// AutoDiffXd overload of DoToGeoPosition().
virtual GeoPositionT<AutoDiffXd> DoToGeoPositionAutoDiff(
const LanePositionT<AutoDiffXd>&) const {
throw std::runtime_error(
"DoToGeoPosition has been instantiated with AutoDiffXd arguments, "
"but a Lane backend has not overridden its AutoDiffXd specialization.");
}
// AutoDiffXd overload of DoToLanePosition().
virtual LanePositionT<AutoDiffXd> DoToLanePositionAutoDiff(
const GeoPositionT<AutoDiffXd>&,
GeoPositionT<AutoDiffXd>*,
AutoDiffXd*) const {
throw std::runtime_error(
"DoToLanePosition has been instantiated with AutoDiffXd arguments, "
"but a Lane backend has not overridden its AutoDiffXd specialization.");
}
// symbolic::Expression overload of DoToGeoPosition().
virtual GeoPositionT<symbolic::Expression> DoToGeoPositionSymbolic(
const LanePositionT<symbolic::Expression>&) const {
throw std::runtime_error(
"DoToGeoPosition has been instantiated with symbolic::Expression "
"arguments, but a Lane backend has not overridden its "
"symbolic::Expression specialization.");
}
// symbolic::Expression overload of DoToLanePosition().
virtual LanePositionT<symbolic::Expression> DoToLanePositionSymbolic(
const GeoPositionT<symbolic::Expression>&,
GeoPositionT<symbolic::Expression>*, symbolic::Expression*) const {
throw std::runtime_error(
"DoToLanePosition has been instantiated with symbolic::Expression "
"arguments, but a Lane backend has not overridden its "
"symbolic::Expression specialization.");
}
// TODO(jadecastro): Template the entire `api::Lane` class to prevent explicit
// virtual functions for each member function.
///@}
};
} // namespace api
} // namespace maliput
} // namespace drake
|
19d6ff22f3a0122f0e5440997d60f29ca2a3fd17
|
6aba3d9e4a5401b5387548475d0ca74794e73c69
|
/GROMACS/nonbonded_benchmark/gromacs_source_code/src/gromacs/commandline/cmdlineinit.h
|
3edd96a265c0950d74b9cacea5a04c3cc7f3314d
|
[
"LicenseRef-scancode-free-unknown",
"MIT",
"LGPL-2.1-only",
"LGPL-2.0-or-later",
"LicenseRef-scancode-sun-rpc",
"LGPL-2.1-or-later",
"SunPro",
"GPL-1.0-or-later",
"BSD-2-Clause-Views",
"GPL-2.0-only",
"BSL-1.0",
"Apache-2.0",
"BSD-3-Clause",
"Zlib",
"BSD-2-Clause"
] |
permissive
|
rvhonorato/bioexcel-exascale-co-design-benchmarks
|
a47b2608ad796329247a671ca95c7b487be213ca
|
41bfd28e64a65f7d08a4195bdfd0024646664351
|
refs/heads/master
| 1,592,459,803,151,669,000
| 1,562,771,865,000,000,000
| 1,562,771,865,000,000,000
| 196,187,655
| 0
| 0
|
MIT
| 1,562,755,825,000,000,000
| 1,562,755,824,000,000,000
| null |
UTF-8
|
C++
| false
| false
| 7,763
|
h
|
cmdlineinit.h
|
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2013,2014,2015,2018, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* GROMACS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GROMACS; if not, see
* http://www.gnu.org/licenses, or write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* If you want to redistribute modifications to GROMACS, please
* consider that scientific software is very special. Version
* control is crucial - bugs must be traceable. We will be happy to
* consider code for inclusion in the official distribution, but
* derived work must not be called official GROMACS. Details are found
* in the README & COPYING files - if they are missing, get the
* official version at http://www.gromacs.org.
*
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
/*! \file
* \brief
* Declares functions for initializing the \Gromacs library for command line use.
*
* \author Teemu Murtola <teemu.murtola@gmail.com>
* \inpublicapi
* \ingroup module_commandline
*/
#ifndef GMX_COMMANDLINE_CMDLINEINIT_H
#define GMX_COMMANDLINE_CMDLINEINIT_H
#include <functional>
#include <memory>
// Forward declaration of class CommandLineProgramContext is not sufficient for
// MSVC if the return value of initForCommandLine() is ignored(!)
#include "gromacs/commandline/cmdlineprogramcontext.h"
namespace gmx
{
class ICommandLineModule;
class ICommandLineOptionsModule;
/*! \brief
* Initializes the \Gromacs library for command-line use.
*
* \param[in] argc argc value passed to main().
* \param[in] argv argv array passed to main().
* \returns Reference to initialized program context object.
*
* This function is tailored for use in command line applications.
* For other usage, combination of gmx::init() and gmx::setProgramContext()
* provides more flexible initialization alternatives.
* Unlike gmx::init(), calls to this method cannot be nested.
*
* The command line arguments are communicated so that they can be
* parsed on each processor.
* \p argc and \p argv are passed to gmx::init(); see there for additional
* discussion. This method does not place any additional limitations, but
* generally there should be no need to pass NULL values.
*
* Does not throw. Terminates the program on out-of-memory error.
*
* This method is not thread-safe, since it is intended to be the first method
* called. See setProgramContext() for additional discussion.
*
* \see gmx::init()
* \see setProgramContext()
* \ingroup module_commandline
*/
CommandLineProgramContext &initForCommandLine(int *argc, char ***argv);
/*! \brief
* Deinitializes the \Gromacs library after initForCommandLine().
*
* Calls gmx::finalize() and additionally undoes the work done by
* initForCommandLine().
*
* \see gmx::finalize()
* \ingroup module_commandline
*/
void finalizeForCommandLine();
/*! \brief
* Handles an exception and deinitializes after initForCommandLine.
*
* \param[in] ex Exception that is the cause for terminating the program.
* \returns Return code to return from main().
*
* This method should be called as the last thing before terminating the
* program because of an exception. See processExceptionAtExit() for details.
* Additionally this method undoes the work done by initForCommandLine.
*
* Does not throw.
*/
int processExceptionAtExitForCommandLine(const std::exception &ex);
/*! \brief
* Implements a main() method that runs a single module.
*
* \param argc \c argc passed to main().
* \param argv \c argv passed to main().
* \param module Module to run.
*
* This method allows for uniform behavior for binaries that only
* contain a single module without duplicating any of the
* implementation from CommandLineModuleManager (startup headers,
* common options etc.).
*
* The signature assumes that \p module construction does not throw
* (because otherwise the caller would need to duplicate all the
* exception handling code). It is possible to move the construction
* inside the try/catch in this method using an indirection similar to
* TrajectoryAnalysisCommandLineRunner::runAsMain(), but until that is
* necessary, the current approach leads to simpler code.
*
* Usage:
* \code
int main(int argc, char *argv[])
{
CustomCommandLineModule module;
return gmx::runCommandLineModule(argc, argv, &module);
}
\endcode
*
* Does not throw. All exceptions are caught and handled internally.
*/
int runCommandLineModule(int argc, char *argv[],
ICommandLineModule *module);
/*! \brief
* Implements a main() method that runs a single module.
*
* \param argc \c argc passed to main().
* \param argv \c argv passed to main().
* \param[in] name Name for the module.
* \param[in] description Short description for the module.
* \param factory Factory method that creates the module to run.
*
* This method allows for uniform behavior for binaries that only
* contain a single module without duplicating any of the
* implementation from CommandLineModuleManager (startup headers,
* common options etc.).
*
* Usage:
* \code
class CustomCommandLineOptionsModule : public ICommandLineOptionsModule
{
// <...>
};
static ICommandLineOptionsModule *create()
{
return new CustomCommandLineOptionsModule();
}
int main(int argc, char *argv[])
{
return gmx::runCommandLineModule(
argc, argv, "mymodule", "short description", &create);
}
\endcode
*
* Does not throw. All exceptions are caught and handled internally.
*/
int runCommandLineModule(int argc, char *argv[],
const char *name, const char *description,
std::function<std::unique_ptr<ICommandLineOptionsModule>()> factory);
} // namespace gmx
/*! \brief
* Implements a main() method that runs a given C main function.
*
* \param argc \c argc passed to main().
* \param argv \c argv passed to main().
* \param mainFunction The main()-like method to wrap.
*
* This method creates a dummy command line module that does its
* processing by calling \p mainFunction. It then runs this module as with
* gmx::runCommandLineModule().
* This allows the resulting executable to handle common options and do
* other common actions (e.g., startup headers) without duplicate code
* in the main methods.
*
* \p mainFunction should call parse_common_args() to process its command-line
* arguments.
*
* Usage:
* \code
int my_main(int argc, char *argv[])
{
// <...>
}
int main(int argc, char *argv[])
{
return gmx_run_cmain(argc, argv, &my_main);
}
\endcode
*
* Does not throw. All exceptions are caught and handled internally.
*/
int gmx_run_cmain(int argc, char *argv[], int (*mainFunction)(int, char *[]));
#endif
|
c20f910a7f1412c802632fd52e83c593633c0af9
|
e68c1f9134b44ddea144f7efa7523076f3f12d3a
|
/FinalCode/DemonHunterGrenadesSlot.h
|
a271d83b6b33a92692ee9c307d52c4d3a014a0ad
|
[] |
no_license
|
iso5930/Direct-3D-Team-Portfolio
|
4ac710ede0c9176702595cba5579af42887611cf
|
84e64eb4e91c7e5b4aed77212cd08cfee038fcd3
|
refs/heads/master
| 1,629,706,500,128,591,000
| 1,512,368,079,000,000,000
| 1,512,368,079,000,000,000
| 112,998,717
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 276
|
h
|
DemonHunterGrenadesSlot.h
|
#pragma once
#include "Slot.h"
class CDemonHunterGrenadesSlot : public CSlot
{
public:
virtual SLOT_RESULT Begin(int _iMode);
virtual SLOT_RESULT Action();
virtual SLOT_RESULT End();
public:
explicit CDemonHunterGrenadesSlot();
virtual ~CDemonHunterGrenadesSlot();
};
|
c4ac44771e23bed33dc2b4ac13d2ba0fa6a0906f
|
faf43f7b2edb703c849d65fa42dde15c8ee42fd1
|
/Code_Arduino_Joystick/NRF24L01.ino
|
87821086720a333c67e1a75ffd515261d09168a3
|
[] |
no_license
|
HUGEFANCY/HF-TeensyControl
|
964dec313023d1c4de634be2eab5b2c22762c623
|
37b98ea3fa7ef2d55f07f86071e40801157c90d9
|
refs/heads/main
| 1,683,469,557,469,039,000
| 1,622,140,565,000,000,000
| 1,622,140,565,000,000,000
| 367,482,080
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,961
|
ino
|
NRF24L01.ino
|
/*
Arduino Wireless Network - Multiple NRF24L01 Tutorial
== Base/ Master Node 00==
by Dejan, www.HowToMechatronics.com
Libraries:
nRF24/RF24, https://github.com/nRF24/RF24
nRF24/RF24Network, https://github.com/nRF24/RF24Network
*/
#include <SPI.h>
#include <RF24Network.h>
#include "RF24.h"
RF24 radio(5, 6); // CE, CSN -> Arduino Pro Mini Board 5, 6
RF24Network network(radio);
const int FunkChannel = 90;
const uint16_t FunkMasterSwitchcabinet = 00; // Address of the other node in Octal format // Switchcabinet, Master
const uint16_t FunkSlaveJoystick = 01; // Joystick, Slave
Metro Metro_FunkCheck = Metro(500);
struct DataPackageIncomming // Max size of this struct is 32 bytes - NRF24L01 buffer limit
{
byte header = 0;
byte val1 = 0; // TargetTemperatureZone_1 (laut Teensy Schatschrank)
byte val2 = 0; // TargetTemperatureZone_2 (laut Teensy Schatschrank)
byte val3 = 0; // RealTemperatureZone_1
byte val4 = 0; // RealTemperatureZone_2
};
DataPackageIncomming dataIncoming; // Create a variable with the above structure
struct DataPackageOutgoing // Max size of this struct is 32 bytes - NRF24L01 buffer limit
{
byte header = 0; // 1 = Temp // 2 = Joystick
byte val1 = 0; // NewTargetTemp_Zone1 // j1PotX;
byte val2 = 0; // NewTargetTemp_Zone2 // j1PotY;
byte val3 = 0; // PwmValuePartCoolingFanMarlin // j1Button;
byte val4 = 0; // j2PotX;
byte val5 = 0; // j2PotY;
byte val6 = 0; // j2Button;
byte val7 = 0; // pot1;
byte val8 = 0; // pot2;
byte val9 = 0; // tSwitch1;
byte val10 = 0; // tSwitch2;
byte val11 = 0; // button1;
byte val12 = 0; // button2;
byte val13 = 0; // button3;
byte val14 = 0; // button4;
};
DataPackageOutgoing dataOutgoing; // Create a variable with the above structure
void setup_Funk()
{
SPI.begin();
radio.begin();
network.begin(FunkChannel, FunkSlaveJoystick); //(channel, node address)
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_2MBPS);
radio.setAutoAck(1); // Ensure autoACK is enabled
radio.setRetries(15, 15);
// delay How long to wait between each retry, in multiples of 250us, max is 15. 0 means 250us, 15 means 4000us.
//count How many retries before giving up, max 15
}
// PWM
boolean FunkData_Temp_PWM()
{
// Send data:
RF24NetworkHeader header(FunkMasterSwitchcabinet); // Address where the data is going
dataOutgoing.header = 1;
//dataOutgoing.val1 = NewTargetTemp_Zone1;
//dataOutgoing.val2 = NewTargetTemp_Zone2;
dataOutgoing.val3 = PwmValuePartCoolingFanMarlin;
boolean ok = network.write(header, &dataOutgoing, sizeof(dataOutgoing)); // Send the data
//Serial.println("Funk DATA Temp!");
if (ok == true)
{
Serial.println("FunkData_Temp_PWM");
return true;
}
else
{
return false;
}
}
// Click Color MODE
boolean FunkData_clickColor(int RadA, int RadB)
{
// Send data:
RF24NetworkHeader header(FunkMasterSwitchcabinet); // Address where the data is going
dataOutgoing.header = 2; // Farbrad
dataOutgoing.val1 = RadA; // RAD A
dataOutgoing.val2 = RadB; // RAD B
dataOutgoing.val3 = 0; // NA
bool ok = network.write(header, &dataOutgoing, sizeof(dataOutgoing)); // Send the data
if (ok == true)
{
Serial.println("Funk DATA Color A!");
return true;
}
else
{
return false;
}
}
boolean FunkData_colorMetronome()
{
// Send data:
RF24NetworkHeader header(FunkMasterSwitchcabinet); // Address where the data is going
dataOutgoing.header = 3; // Farbrad colorMetronome
dataOutgoing.val1 = ColorTime255_L; // RAD L
dataOutgoing.val2 = ColorTime255_R; // RAD R
dataOutgoing.val3 = ColorTime255_shift; // shift LR
bool ok = network.write(header, &dataOutgoing, sizeof(dataOutgoing)); // Send the data
if (ok == true)
{
Serial.println("Funk DATA Color Periodisch!");
return true;
}
else
{
return false;
}
}
void loop_FunkCheck()
{
//===== Receiving =====//
network.update();
while (network.available()) // Is there any incoming data?
{
RF24NetworkHeader header(FunkMasterSwitchcabinet);
network.read(header, &dataIncoming, sizeof(dataIncoming)); // Read the incoming data
if ((header.from_node == FunkMasterSwitchcabinet) and (dataIncoming.header == 1))
{
//Serial.println("Switchcabinet hat was gefunkt");
if ((dataIncoming.val1 != TargetTemperatureZone_1) and (NewTargetTempAvalible_Zone1 == false))
{
TargetTemperatureZone_1 = dataIncoming.val1;
}
if ((dataIncoming.val2 != TargetTemperatureZone_2) and (NewTargetTempAvalible_Zone2 == false))
{
TargetTemperatureZone_2 = dataIncoming.val2;
}
if (dataIncoming.val3 != RealTemperatureZone_1)
{
RealTemperatureZone_1 = dataIncoming.val3;
}
if (dataIncoming.val4 != RealTemperatureZone_2)
{
RealTemperatureZone_2 = dataIncoming.val4;
}
}
}
}
|
2e3247e6f9efd605d901f89f924f1311c930e6b8
|
4e4d37ebdd240113bd52d9b5bd828fc4c8ebd4d0
|
/Occupancy4.ino
|
9b2a55762417fb83d16b280b28d83907406cc3df
|
[] |
no_license
|
Raja-Raman/IoT4
|
c7f0e73afb8eb65c1ef3e1c13bd1d96efcf32811
|
630f4c8e43e2eb95b301a11239b9083774bc43c7
|
refs/heads/master
| 1,618,778,424,093,627,000
| 1,522,835,094,000,000,000
| 1,522,835,094,000,000,000
| 126,720,643
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,901
|
ino
|
Occupancy4.ino
|
// Smart building: occupancy, temperature and humidity
// TODO: periodically try to connect to the RF mesh; but if not, keep running the lights
/*----------------------------------------------------------------------------
NRF24 connections
http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
1 - GND
2 - VCC 3.3V *** (5V allowed Only if you are using the NRF base module)
3 - CE to Arduino pin 7
4 - CSN to Arduino pin 8
5 - SCK to Arduino pin 13
6 - MOSI to Arduino pin 11
7 - MISO to Arduino pin 12
8 - IRQ (UNUSED)
---------------------------------------------------------------------------- */
#include <EEPROM.h> // bundled with Arduino IDE
#include <SPI.h> // bundled with Arduino IDE
#include "Timer.h" // Simon Monk: http://www.simonmonk.org -> Jack Christensen
#include "RF24.h" // TMRH2o : https://github.com/TMRh20/RF24
#include "RF24Network.h" // http://tmrh20.github.io/RF24Network/
#include "RF24Mesh.h" // http://tmrh20.github.io/RF24Mesh/
#include <dht.h> // Rob Tillaart: https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib
// *** increment the following node id before burning it to every Arduino: ***
#define nodeID 4
#define SIMULATION 0 // 0 for production hardware
#define NORELAY 1
const byte FREE_PIN = A7; // any unconnected analog pin
const byte pir1 = 3; // HC-SR 501
const byte pir2 = A0; // HC-SR 501
const byte radar = 4; // RCWL 0516
const byte dhtsensor = A2; // DHT 11
const byte led = 5; // active low
const byte buzzer = A3; // active low
const byte relay = 9; // active high
dht D;
Timer T;
RF24 radio(7, 8); // (CE, CS pins)
RF24Network network(radio);
RF24Mesh mesh(radio, network);
// * Timer durations SHOULD be unsigned LONG int, if they are > 16 bit!
unsigned int tick_interval = 100; // in milliSec; 10 ticks = 1 second
unsigned int status_ticks = 5*10; // n*10 ticks = n seconds
unsigned int release_ticks = 120*10; // n*10 ticks = n seconds
unsigned int buzzer_ticks = 110*10; // n*10 ticks = n seconds
unsigned int data_interval = 10*1000; // directly in milli seconds
unsigned int tick_counter = 0;
unsigned int status_counter = 0;
unsigned long network_check_interval = 60000UL;
byte num_hits = 0; // number of sensors that fired
byte release_duration = 2; // can be 1,2 or 3 minutes
int temperature = 0; // DHT11 only gives integers
int humidity = 0; // DHT22 can give decimal accuracy
boolean auto_mode = true; // false->manual mode; TODO:implement manual mode
byte mute_buzzer = 1; // TODO: 1 for production
boolean occupied = true; // occupancy status of the room
struct {
byte node_id; // 1 to 255
byte occupied;
unsigned int temperature;
unsigned int humidity;
} status_payload;
struct {
char command; // command name; TODO: implement manual commands
unsigned int value; // some parameter, in the context of the command
} command_payload;
void(* software_reset) (void) = 0; //declare reset function - jump to address 0
void setup() {
pinMode(led, OUTPUT);
pinMode(relay, OUTPUT);
pinMode(buzzer, OUTPUT);
if (!NORELAY)
digitalWrite(relay, HIGH); // active high; start with relay operated
digitalWrite(led, HIGH); // active low
digitalWrite(buzzer, HIGH); // active low
pinMode(dhtsensor, INPUT);
pinMode(radar, INPUT);
pinMode(pir1, INPUT);
pinMode(pir2, INPUT);
//beeper(0); // TODO: disable this for production
blinker();
Serial.begin(9600);
Serial.println(F("Occupancy sensor starting..."));
//EEPROM.get(0, mute_buzzer); // TODO: save tick interval also in EEPROM
// Set the nodeID manually
mesh.setNodeID(nodeID); // increment this when burning every device
status_payload.node_id = nodeID;
Serial.print(F("Slave Node ID: "));
Serial.println(nodeID);
Serial.print(F("Simulation = "));Serial.println(SIMULATION);
Serial.print(F("NORELAY = "));Serial.println(NORELAY);
Serial.println(F("Connecting to the mesh..."));
unsigned long ms = millis();
bool result = mesh.begin(MESH_DEFAULT_CHANNEL,RF24_1MBPS,8000);
Serial.println(F("Time taken: "));
Serial.println(millis()-ms);
if (result)
Serial.println(F("Connected to mesh."));
else
Serial.println(F("Connection timed out."));
/*
int palevel = radio.getPALevel();
Serial.print(F("Radio PA level: "));
Serial.println(palevel);
radio.setPALevel (RF24_PA_LOW);
Serial.print(F("New PA level: "));
palevel = radio.getPALevel();
Serial.println(palevel);
Serial.println(F("Joined the meash."));
*/
randomSeed(analogRead(FREE_PIN)); // noise from an unconnected pin
status_ticks = status_ticks + random(0, 10); // stagger the transmissions
Serial.print(F("Status tick interval: "));
Serial.println(status_ticks*100U); // convert to mSec
T.every(tick_interval, ticker);
T.every(data_interval, read_temperature); // just update readings; do not send it
T.every(network_check_interval, renew_network); // check connection and renew if necessary
occupy_room(); // start life in occupied state (this needs the mesh running)
}
void loop() {
T.update();
mesh.update(); // keep the network updated
}
void ticker(){
read_sensors(); // read PIR and radar...
update_status(); // ...and then compute occupancy status
if (network.available()) // this is usually a while() loop
read_command();
}
// You MUST call this before calling update_status
void read_sensors() {
num_hits = 0; // global variable
num_hits += digitalRead(radar);
num_hits += digitalRead(pir1);
num_hits += digitalRead(pir2);
digitalWrite (led, (num_hits==0)); // active low
}
// uses the global variable num_hits: Call read_sensors before calling this !
void update_status() {
if (!occupied && auto_mode)
if (num_hits > 1) // at least two sensors fired - occupy the room
occupy_room();
if (num_hits > 0) // at least one fired; so the room is in use
tick_counter = 0; // keep resetting it, if there is any motion
tick_counter++; // Note: the sensors can keep tick_counter perpetually zero! So,
status_counter++; // you need a separate status_counter
if (status_counter == status_ticks) {
send_status();
status_counter = 0;
}
if (tick_counter == buzzer_ticks) {
if (occupied && auto_mode)
warn(); // warn about the imminent release
}
else
if (tick_counter >= release_ticks){
tick_counter = 0;
if (occupied && auto_mode)
release_room();
}
}
void occupy_room() {
if (!NORELAY)
digitalWrite(relay, HIGH); // active high
occupied = true;
if (!mute_buzzer)
T.pulse (buzzer, 200, HIGH); // active low // 100
// the end state is HIGH, i.e, buzzer is off *
send_status();
}
// pre-release warning beeps
void warn() {
T.oscillate (buzzer,50, HIGH, 4);
// the end state is HIGH, i.e, buzzer is off *
}
void release_room() {
if (!NORELAY)
digitalWrite(relay, LOW); // active high
occupied = false;
send_status();
}
// this is independently running under a timer
void read_temperature() {
// Reading the DHT11 takes about 250 milliseconds
D.read11(dhtsensor);
temperature = D.temperature;
humidity = D.humidity;
}
// the temperature and humidity are updated independently by another timer
boolean result;
void send_status() {
if (SIMULATION) {
status_payload.occupied = random(0,2); // [min, max)
status_payload.temperature = random(0, 40);
status_payload.humidity = random(0,100);
}
else {
status_payload.occupied = occupied;
status_payload.temperature = temperature;
status_payload.humidity = humidity;
}
// TODO: disable this for production
Serial.print(status_payload.occupied ? "Occupied, " : "Free, ");
Serial.print(status_payload.temperature);
Serial.print(F(", "));
Serial.print(status_payload.humidity);
result = mesh.write(&status_payload, 'S', sizeof(status_payload));
if (result)
Serial.println();
else
Serial.println(F(" (Send failed)*"));
}
bool renew_network() {
if (mesh.checkConnection()) {
return (true);
}
else {
Serial.println(F("Renewing network address..."));
unsigned int addr = mesh.renewAddress(3000UL);
if (addr != 0) {
Serial.print(F("New address: "));
Serial.println(addr);
return (true);
}
}
return (false);
}
// TODO: combine this with execute_command()
RF24NetworkHeader in_header;
void read_command() {
network.read(in_header, &command_payload, sizeof(command_payload));
Serial.print(F("Received <- Header.From: 0"));
Serial.print(in_header.from_node, OCT);
Serial.print(F(" command: "));
Serial.println(command_payload.command);
//Serial.print(F(" value: "));
//Serial.println(command_payload.value);
if (command_payload.command == 'R') {
Serial.println(F("\r\nGot reset command from Master!! "));
Serial.println(F("\nRestarting in 5 seconds.... "));
delay(5000);
software_reset();
}
}
void blinker() {
for (int i=0; i<5; i++) { // 10
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(100);
}
}
void beeper (int mode) {
switch (mode) {
case 0: // useful before entering T.update loop
digitalWrite(buzzer, LOW); // active low
delay(200);
digitalWrite(buzzer, HIGH);
break;
case 1:
T.pulse(buzzer, 4000, HIGH); // active low
break;
default:
T.pulse(buzzer, 200, HIGH); // active low
break;
}
}
/*****************
void init_radio() {
myRadio.begin(); // Start up the physical nRF24L01 Radio
myRadio.setChannel(108); // Above most Wifi Channels
// Set the PA Level low to prevent power supply related issues
myRadio.setPALevel(RF24_PA_MIN);
//myRadio.setPALevel(RF24_PA_HIGH);
//myRadio.setPALevel(RF24_PA_MAX); // Uncomment for more power
myRadio.setDataRate( RF24_250KBPS );
Serial.println(F("About to open NRF pipe..."));
myRadio.openWritingPipe( addresses[0]);
delay(1000);
Serial.println(F("Writing pipe opened."));
}
void execute_command() {
switch (rxbyte) { // rxbyte is a global variable **
case 'a':
auto_mode = true;
break;
case 'm':
auto_mode = false;
break;
case 'n':
if (!auto_mode)
occupy_room();
break;
case 'f':
if (!auto_mode)
release_room();
break;
case '1':
case '2':
case '3':
release_duration = rxbyte-'0'; // 1,2 or 3 minutes
release_ticks = release_duration*60*10; // N*60*10*(100 mSec_ticks) = N minutes
buzzer_ticks = release_ticks-100; // 100 msec*(100 ticks) = 10 seconds before release
break;
case 'b':
mute_buzzer = (mute_buzzer ? 0:1);
EEPROM.put(0, mute_buzzer);
// fall through to reset
case 'r':
software_reset();
break;
default:
break;
}
send_status();
}
***************************/
|
9c35787c0a65080f0ac4977a26e773d2c42f6e29
|
c1a7c1d29b4697cb5c7b7f71cb37c6e80da1c902
|
/c++/H2/16 H2.cpp
|
f200c4cf235271b5c517bb287018b222d8ff6de8
|
[] |
no_license
|
DanielaDominguez/ESFM-
|
af96f939c3f71427829c0ee88749e9ea6e4a72a2
|
a08a1d1f3012e971fed4cf1610945dff7cce74a1
|
refs/heads/master
| 1,690,635,147,707,494,000
| 1,631,335,307,000,000,000
| 1,631,335,307,000,000,000
| 405,282,161
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 418
|
cpp
|
16 H2.cpp
|
#include<iostream>
using namespace std;
int main() {
float acum;
float dato;
int i;
int n;
float prom;
cout << "Ingrese la cantidad de alumnos:" << endl;
cin >> n;
acum = 0;
for (i=1;i<=n;i++) {
cout << "Ingrese la edad " << i << ":" << endl;
cin >> dato;
acum = acum+dato;
}
prom = acum/n;
cout << "El promedio de las edades del grupo de " << n << " alumnos es: " << prom << endl;
return 0;
}
|
23cbfd0b599091bbdcb68cf220024a5abd1020f7
|
cfb0bd74e07fed80b519931db318e5d75aad25f2
|
/platform/JS/Core/src/Wrapper.cpp
|
94008478ef106290840111302ea1977a354e2f7b
|
[
"Apache-2.0"
] |
permissive
|
leisen2009/macchina.io
|
c17d8632e2ddacf4d9f059dec1d2248ae5a3ff02
|
60e2688707c996abc2e9a1eaab1091b3fb16a2bd
|
refs/heads/develop
| 1,609,354,679,869,471,000
| 1,451,234,347,000,000,000
| 1,451,234,347,000,000,000
| 30,900,580
| 0
| 0
| null | 1,424,142,899,000,000,000
| 1,424,142,898,000,000,000
| null |
UTF-8
|
C++
| false
| false
| 578
|
cpp
|
Wrapper.cpp
|
//
// Wrapper.cpp
//
// $Id: //poco/1.4/JS/Core/src/Wrapper.cpp#4 $
//
// Library: JSCore
// Package: JSCore
// Module: Wrapper
//
// Copyright (c) 2013-2014, Applied Informatics Software Engineering GmbH.
// All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
#include "Poco/JS/Core/Wrapper.h"
namespace Poco {
namespace JS {
namespace Core {
Wrapper::Wrapper()
{
}
Wrapper::~Wrapper()
{
}
std::string Wrapper::toString(v8::Local<v8::Value> value)
{
v8::String::Utf8Value utf8(value);
return std::string(*utf8);
}
} } } // namespace Poco::JS::Core
|
7d3ee327e9ecf93fcb18d5f53b507b3839ad8dd4
|
7df578885d6377d6ab17109dc327549c3e698b6c
|
/Recursion/Subset Sums.cpp
|
b526d6c52d83d17f5a62117c331094ad0e431f63
|
[] |
no_license
|
jainamandelhi/Geeks-For-Geeks-Solutions
|
b102dc8801760f2723e3c0783ebd134853f988d2
|
1851f3ab38ddde85b14c13a7834f5391e9780e65
|
refs/heads/master
| 1,585,032,330,783,081,000
| 1,566,050,147,000,000,000
| 1,566,050,147,000,000,000
| 142,540,641
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 847
|
cpp
|
Subset Sums.cpp
|
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
#define ll long long
ll mod=1000000007;
ll gcd(ll a,ll b)
{
return (b==0)?a:gcd(b,a%b);
}
ll n;
bool comp(ll i,ll j)
{
return i>j;
}
map<ll,ll>st;
void dfs(ll i, ll sum,ll arr[])
{
if(i==n)
{
st[sum]++;
return;
}
dfs(i+1,sum+arr[i],arr);
dfs(i+1,sum,arr);
}
void solve()
{
cin>>n;
ll arr[n];
for(ll i=0;i<n;i++)
cin>>arr[i];
dfs(0,0,arr);
// cout<<41243431;
map<ll,ll>::iterator itr;
for(itr=st.begin();itr!=st.end();itr++)
{
while(itr->second!=0)
{
cout<<itr->first<<" ";
itr->second--;
}
}
cout<<endl;
}
int main()
{
ll t;
cin>>t;
while(t--)
solve();
}
|
cc497ed31047fb41e36e70453f1de34029adeedc
|
f8b3d4336226921fd273c22c8b9b97fde46deab8
|
/src/zaxlib_struct.hpp
|
9c6ea0f5491c9a84caa1696aa82626458f5da597
|
[] |
no_license
|
zaxhutchinson/project_thing
|
2273a299cea95da16ffd51300010abad2baa1565
|
1b34f6a3eb32d16b28787c0e8b22c0ee00122b5b
|
refs/heads/master
| 1,585,261,520,270,432,000
| 1,538,826,740,000,000,000
| 1,538,826,740,000,000,000
| 145,457,450
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 822
|
hpp
|
zaxlib_struct.hpp
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: zaxlib_struct.hpp
* Author: zax
*
* Created on November 30, 2017, 10:22 AM
*/
#ifndef ZAXLIB_STRUCT_HPP
#define ZAXLIB_STRUCT_HPP
#include<memory>
#include<string>
#include"zaxlib_templates.hpp"
#include "zaxlib_enum.hpp"
struct SpikeField {
int curtime;
int elements;
vec_uptr<bool> spikes;
vec_uptr<std::string> names;
};
struct InputSwitch {
InputSwitch() {
output = OutputType::None;
}
vec<InputType> types;
OutputType output;
};
struct NeuronData {
std::string filename;
unsigned int buffer_size;
vec<int64_t> spikes;
};
#endif /* ZAXLIB_STRUCT_HPP */
|
7b21f35f1ff1b08e49eef7ae55ac01b8955d1081
|
c71af56951d1c661a5819db72da1caccd9130df2
|
/cpp/problems/syntax/syntax102.cpp
|
134657bbd369fad5917470e40d799845f31d94a8
|
[] |
no_license
|
adrianpoplesanu/personal-work
|
2940a0dc4e4e27e0cc467875bae3fdea27dd0d31
|
adc289ecb72c1c6f98582f3ea9ad4bf2e8e08d29
|
refs/heads/master
| 1,692,773,809,363,519,000
| 1,692,638,451,000,000,000
| 1,692,638,451,000,000,000
| 109,451,981
| 0
| 1
| null | 1,665,118,404,000,000,000
| 1,509,752,181,000,000,000
|
Python
|
UTF-8
|
C++
| false
| false
| 712
|
cpp
|
syntax102.cpp
|
// overriding ++ prefix and postfix operators
#include <iostream>
using namespace std;
class Elev {
private:
int age;
public:
Elev();
int GetAge();
void SetAge(int);
Elev& operator ++();
Elev operator ++(int);
};
Elev::Elev() : age(18) {
};
int Elev::GetAge() {
return age;
}
void Elev::SetAge(int val) {
age = val;
}
Elev& Elev::operator ++() {
age++;
return *this;
}
Elev Elev::operator ++(int) {
Elev temp;
temp.SetAge(age);
++(*this);
return temp;
}
int main(int argc, char *argv[]) {
Elev elev;
cout << elev.GetAge() << endl;
++elev;
cout << elev.GetAge() << endl;
elev++;
cout << elev.GetAge() << endl;
return 0;
}
|
f62742a203418cc9775bc601f996c14fdde6bb6e
|
1a2552f1941318b4aa854a6f8306b40344874f23
|
/src/util/string/rstring.tcc
|
4fd6debd056a858448a0dae9ab5f7e418f575b2b
|
[
"GPL-3.0-or-later",
"Zlib",
"BSL-1.0",
"Apache-2.0",
"LicenseRef-scancode-flex-2.5",
"LicenseRef-scancode-mit-old-style",
"W3C",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-1.0-or-later",
"LicenseRef-scancode-proprietary-license",
"LGPL-2.0-or-later",
"LicenseRef-scancode-swig",
"ICU",
"LicenseRef-scancode-other-copyleft",
"CC-BY-ND-3.0",
"LicenseRef-scancode-unknown-license-reference",
"curl",
"LGPL-2.1-or-later",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"MIT"
] |
permissive
|
zorba-processor/zorba
|
23176504346703a6e6f48a37f10844ef170774ab
|
7a7d77144521029c230359d9f54c83ab8ec71ac7
|
refs/heads/master
| 1,670,766,574,429,854,000
| 1,662,469,697,000,000,000
| 1,662,469,697,000,000,000
| 59,799,419
| 44
| 20
|
Apache-2.0
| 1,668,646,400,000,000,000
| 1,464,317,763,000,000,000
|
C++
|
UTF-8
|
C++
| false
| false
| 15,122
|
tcc
|
rstring.tcc
|
/*
* Copyright 2006-2016 zorba.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ZORBA_RSTRING_TCC
#define ZORBA_RSTRING_TCC
#ifndef ZORBA_RSTRING_H
#error "This file is not meant to be included directly."
#endif /* ZORBA_RSTRING_H */
#include <algorithm>
#ifdef WIN32
// Windows annoyingly defines these as macros.
#undef min
#undef max
#endif
namespace zorba {
////////// out-of-line member function definitions ////////////////////////////
// RSTRING_APPEND_SAFE_CP_ST_CP_ST_X
template<class Rep> void
rstring<Rep>::append_safe( const_pointer s1, size_type n1, const_pointer s2,
size_type n2 ) {
if ( size_type add_len = n1 + n2 ) {
size_type const len = size();
mutate( len, 0, add_len );
if ( n1 )
Rep::copy( data() + len, s1, n1 );
if ( n2 )
Rep::copy( data() + len + n1, s2, n2 );
}
}
// RSTRING_APPEND_RS_2ST_X
template<class Rep> rstring<Rep>&
rstring<Rep>::append( rstring const &s, size_type s_pos, size_type s_n ) {
s.check_pos( s_pos, "append" );
s_n = s.limit_n( s_pos, s_n );
if ( s_n )
append_safe( s.data() + s_pos, s_n );
return *this;
}
// RSTRING_APPEND_TS_2ST_X
template<class Rep>
template<class Rep2> rstring<Rep>&
rstring<Rep>::append( rstring<Rep2> const &s, size_type s_pos, size_type s_n ) {
s.check_pos( s_pos, "append" );
s_n = s.limit_n( s_pos, s_n );
if ( s_n )
append_safe( s.data() + s_pos, s_n );
return *this;
}
// RSTRING_APPEND_SS_2ST_X
template<class Rep> rstring<Rep>&
rstring<Rep>::append( std_string const &s, size_type s_pos, size_type n ) {
s.at( s_pos );
n = limit_n( s_pos, s.size(), n );
if ( n )
append_safe( s.data() + s_pos, n );
return *this;
}
// RSTRING_APPEND_CP_ST_X
template<class Rep> rstring<Rep>&
rstring<Rep>::append( const_pointer s, size_type s_len ) {
if ( s_len ) {
size_type const len = size();
if ( disjunct( s ) ) {
mutate( len, 0, s_len );
} else {
size_type const off = s - data();
mutate( len, 0, s_len );
s = data() + off;
}
Rep::copy( data() + len, s, s_len );
}
return *this;
}
// RSTRING_APPEND_ST_VT_X
template<class Rep> rstring<Rep>&
rstring<Rep>::append( size_type n, value_type c ) {
if ( n ) {
size_type const len = size();
mutate( len, 0, n );
assign_opt( data() + len, n, c );
}
return *this;
}
template<class Rep> void
rstring<Rep>::push_back( value_type c ) {
size_type const len = size();
mutate( len, 0, 1 );
traits_type::assign( data()[ len ], c );
}
// RSTRING_ASSIGN_RS_X
template<class Rep> rstring<Rep>&
rstring<Rep>::assign( rstring const &s ) {
if ( rep() != s.rep() ) {
rep().dispose( get_allocator() );
rep().share( s.rep(), get_allocator(), s.get_allocator() );
}
return *this;
}
// RSTRING_ASSIGN_CP_ST_X
template<class Rep> rstring<Rep>&
rstring<Rep>::assign( const_pointer s, size_type n ) {
if ( disjunct( s ) || rep().is_shared() )
replace_safe( 0, size(), s, n );
else {
size_type const pos = s - data();
if ( pos > n )
Rep::copy( data(), s, n );
else
Rep::move( data(), s, n );
rep().set_length( n );
}
return *this;
}
// RSTRING_ASSIGN_P_ST_X
template<class Rep> rstring<Rep>&
rstring<Rep>::assign( pointer s, size_type n ) {
allocator_type const a = get_allocator();
rep().dispose( a );
rep().construct( s, s + n, a );
return *this;
}
// RSTRING_CONSTRUCT_CP_ST_X
template<class Rep> rstring<Rep>&
rstring<Rep>::wrap_memory( const_pointer s, size_type n ) {
allocator_type const a = get_allocator();
rep().dispose( a );
rep().construct( s, s + n, a );
return *this;
}
// RSTRING_COMPARE_RS_X
template<class Rep> int
rstring<Rep>::compare( rstring const &s ) const {
size_type const len = size();
size_type const s_len = s.size();
size_type const n = std::min( len, s_len );
int const comp = traits_type::compare( data(), s.data(), n );
return comp ? comp : compare( len, s_len );
}
// RSTRING_COMPARE_CP_ST_X
template<class Rep> int
rstring<Rep>::compare( const_pointer s, size_type s_n ) const {
size_type const len = size();
size_type const min_n = std::min( len, s_n );
int const comp = traits_type::compare( data(), s, min_n );
return comp ? comp : compare( len, s_n );
}
// RSTRING_COMPARE_2ST_RS_X
template<class Rep> int
rstring<Rep>::compare( size_type pos, size_type n, rstring const &s ) const {
check_pos( pos, "compare" );
n = limit_n( pos, n );
size_type const s_len = s.size();
size_type const min_n = std::min( n, s_len );
int const comp = traits_type::compare( data() + pos, s.data(), min_n );
return comp ? comp : compare( n, s_len );
}
// RSTRING_COMPARE_2ST_CP_X
template<class Rep> int
rstring<Rep>::compare( size_type pos, size_type n, const_pointer s ) const {
check_pos( pos, "compare" );
n = limit_n( pos, n );
size_type const s_len = traits_type::length( s );
size_type const min_n = std::min( n, s_len );
int const comp = traits_type::compare( data() + pos, s, min_n );
return comp ? comp : compare( n, s_len );
}
// RSTRING_COMPARE_2ST_RS_2ST_X
template<class Rep> int
rstring<Rep>::compare( size_type pos, size_type n, rstring const &s,
size_type s_pos, size_type s_n ) const {
check_pos( pos, "compare" );
s.check_pos( s_pos, "compare" );
n = limit_n( pos, n );
s_n = limit_n( s_pos, s_n );
size_type const min_n = std::min( n, s_n );
int const comp =
traits_type::compare( data() + pos, s.data() + s_pos, min_n );
return comp ? comp : compare( n, s_n );
}
// RSTRING_COMPARE_2ST_CP_ST_X
template<class Rep> int
rstring<Rep>::compare( size_type pos, size_type n, const_pointer s,
size_type s_n ) const {
check_pos( pos, "compare" );
n = limit_n( pos, n );
size_type const min_n = std::min( n, s_n );
int const comp = traits_type::compare( data() + pos, s, min_n );
return comp ? comp : compare( n, s_n );
}
// RSTRING_COPY_P_2ST_X
template<class Rep> typename rstring<Rep>::size_type
rstring<Rep>::copy( pointer buf, size_type n, size_type pos ) const {
check_pos( pos, "copy" );
n = limit_n( pos, n );
if ( n )
Rep::copy( buf, data(), n );
return n;
}
// RSTRING_FIND_CP_2ST_X
template<class Rep> typename rstring<Rep>::size_type
rstring<Rep>::find( const_pointer s, size_type pos, size_type n ) const {
size_type const len = size();
if ( !n )
return pos <= len ? pos : npos;
if ( n <= len ) {
for ( ; pos <= len - n; ++pos )
if ( traits_type::eq( data()[ pos ], s[0] ) &&
traits_type::compare( data() + pos + 1, s + 1, n - 1 ) == 0 )
return pos;
}
return npos;
}
// RSTRING_FIND_VT_ST_X
template<class Rep> typename rstring<Rep>::size_type
rstring<Rep>::find( value_type c, size_type pos ) const {
size_type const len = size();
if ( pos < len ) {
if ( const_pointer p = traits_type::find( data() + pos, len - pos, c ) )
return p - data();
}
return npos;
}
// RSTRING_FIND_FIRST_OF_CP_2ST_X
template<class Rep> typename rstring<Rep>::size_type
rstring<Rep>::find_first_of( const_pointer s, size_type pos,
size_type s_n ) const {
for ( ; s_n && pos < size(); ++pos ) {
if ( traits_type::find( s, s_n, data()[ pos ] ) )
return pos;
}
return npos;
}
// RSTRING_FIND_FIRST_NOT_OF_CP_2ST_X
template<class Rep> typename rstring<Rep>::size_type
rstring<Rep>::find_first_not_of( const_pointer s, size_type pos,
size_type s_n ) const {
for ( ; pos < size(); ++pos )
if ( !traits_type::find( s, s_n, data()[ pos ] ) )
return pos;
return npos;
}
// RSTRING_FIND_FIRST_NOT_OF_VT_ST_X
template<class Rep> typename rstring<Rep>::size_type
rstring<Rep>::find_first_not_of( value_type c, size_type pos ) const {
for ( ; pos < size(); ++pos )
if ( !traits_type::eq( data()[ pos ], c ) )
return pos;
return npos;
}
// RSTRING_FIND_LAST_OF_CP_2ST_X
template<class Rep> typename rstring<Rep>::size_type
rstring<Rep>::find_last_of( const_pointer s, size_type pos,
size_type s_n ) const {
size_type len = size();
if ( len && s_n ) {
if ( --len > pos )
len = pos;
do {
if ( traits_type::find( s, s_n, data()[ len ] ) )
return len;
} while ( --len );
}
return npos;
}
// RSTRING_FIND_LAST_NOT_OF_CP_2ST_X
template<class Rep> typename rstring<Rep>::size_type
rstring<Rep>::find_last_not_of( const_pointer s, size_type pos,
size_type s_n ) const {
if ( size_type len = size() ) {
if ( --len > pos )
len = pos;
do {
if ( !traits_type::find( s, s_n, data()[ len ] ) )
return len;
} while ( len-- );
}
return npos;
}
// RSTRING_FIND_LAST_NOT_OF_VT_ST_X
template<class Rep> typename rstring<Rep>::size_type
rstring<Rep>::find_last_not_of( value_type c, size_type pos ) const {
if ( size_type len = size() ) {
if ( --len > pos )
len = pos;
do {
if ( !traits_type::eq( data()[ len ], c ) )
return len;
} while ( len-- );
}
return npos;
}
// RSTRING_RFIND_CP_2ST_X
template<class Rep> typename rstring<Rep>::size_type
rstring<Rep>::rfind( const_pointer s, size_type pos, size_type s_n ) const {
size_type const len = size();
if ( s_n <= len ) {
pos = std::min( len - s_n, pos );
do {
if ( traits_type::compare( data() + pos, s, s_n ) == 0 )
return pos;
} while ( pos-- > 0 );
}
return npos;
}
// RSTRING_RFIND_VT_ST_X
template<class Rep> typename rstring<Rep>::size_type
rstring<Rep>::rfind( value_type c, size_type pos ) const {
if ( size_type len = size() ) {
if ( --len > pos )
len = pos;
for ( ++len; len-- > 0; )
if ( traits_type::eq( data()[ len ], c ) )
return len;
}
return npos;
}
// RSTRING_INSERT_ST_CP_ST_X
template<class Rep> rstring<Rep>&
rstring<Rep>::insert( size_type pos, const_pointer s, size_type s_n ) {
check_pos( pos, "insert" );
if ( disjunct( s ) || rep().is_shared() )
return replace_safe( pos, 0, s, s_n );
size_type const off = s - data();
mutate( pos, 0, s_n );
s = data() + off;
pointer p = data() + pos;
if ( s + s_n <= p )
Rep::copy( p, s, s_n );
else if ( s >= p )
Rep::copy( p, s + s_n, s_n );
else {
size_type const nleft = p - s;
Rep::copy( p, s, nleft );
Rep::copy( p + nleft, p + s_n, s_n - nleft );
}
return *this;
}
template<class Rep> void
rstring<Rep>::mutate( size_type pos, size_type n1, size_type n2 ) {
size_type const old_size = size();
size_type const new_size = old_size + n2 - n1;
size_type const how_much = old_size - pos - n1;
if ( new_size > capacity() || rep().is_shared() ) {
// must reallocate
allocator_type const a = get_allocator();
// TODO: if new_size == 0, use empty_rep()
rep_proxy_type new_rep;
// The call to construct will throw an error if the RepType is the buf_rep
new_rep.realloc( new_size, capacity(), a );
if ( pos )
Rep::copy( new_rep.data(), data(), pos );
if ( how_much )
Rep::copy( new_rep.data() + pos + n2, data() + pos + n1, how_much );
rep().take( new_rep, a, a );
}
else if ( how_much && n1 != n2 ) {
// in-place
Rep::move( data() + pos + n2, data() + pos + n1, how_much );
}
rep().set_length( new_size );
}
// RSTRING_REPLACE_2ST_CP_ST_X
template<class Rep> rstring<Rep>&
rstring<Rep>::replace( size_type pos, size_type n, const_pointer s,
size_type s_n ) {
check_pos( pos, "replace" );
n = limit_n( pos, n );
if ( disjunct( s ) || rep().is_shared() )
return replace_safe( pos, n, s, s_n );
bool left = s + s_n <= data() + pos;
if ( left || data() + pos + n <= s ) {
size_type off = s - data();
if ( !left )
off += s_n - n;
mutate( pos, n, s_n );
Rep::copy( data() + pos, data() + off, s_n );
}
return *this;
}
// RSTRING_REPLACE_2I_2II_X
template<class Rep>
template<class InputIterator> rstring<Rep>&
rstring<Rep>::replace( iterator i, iterator j,
InputIterator ii, InputIterator ij ) {
rstring const temp( ii, ij );
return replace_safe( i - ibegin(), j - i, temp.data(), temp.size() );
}
// RSTRING_RESIZE_ST_VT_X
template<class Rep> void
rstring<Rep>::resize( size_type new_size, value_type c ) {
size_type const len = size();
if ( len < new_size )
append( new_size - len, c);
else if ( new_size < len )
erase( new_size );
}
// RSTRING_SWAP_RS_X
template<class Rep> void
rstring<Rep>::swap( rstring &s ) {
if ( !rep().is_sharable() )
rep().set_sharable();
if ( !s.rep().is_sharable() )
s.rep().set_sharable();
if ( get_allocator() == s.get_allocator() ) {
rep().swap( s.rep() );
} else {
rstring const temp1( ibegin(), iend(), s.get_allocator() );
rstring const temp2( s.ibegin(), s.iend(), get_allocator() );
*this = temp2;
s = temp1;
}
}
////////// out-of-line global function definitions ////////////////////////////
template<typename CharType,class TraitsType,class Rep>
std::basic_istream<CharType,TraitsType>&
getline( std::basic_istream<CharType,TraitsType> &is, rstring<Rep> &s,
typename rstring<Rep>::value_type delim ) {
typedef std::basic_istream<CharType,TraitsType> istream_type;
typedef typename istream_type::int_type int_type;
typedef std::basic_streambuf<CharType,TraitsType> streambuf_type;
typedef rstring<Rep> string_type;
typedef typename string_type::size_type size_type;
std::ios_base::iostate err = std::ios_base::iostate( std::ios_base::goodbit );
size_type extracted = 0;
int_type const idelim = TraitsType::to_int_type( delim );
int_type const eof = TraitsType::eof();
s.clear();
try {
streambuf_type *const sb = is.rdbuf();
int_type c = sb->sgetc();
while ( !TraitsType::eq_int_type( c, eof ) &&
!TraitsType::eq_int_type( c, idelim ) ) {
s += TraitsType::to_char_type( c );
++extracted;
c = sb->snextc();
}
if ( TraitsType::eq_int_type( c, eof ) )
err |= std::ios_base::eofbit;
else if ( TraitsType::eq_int_type( c, idelim ) ) {
++extracted;
sb->sbumpc();
} else
err |= std::ios_base::failbit;
}
catch ( ... ) {
is.setstate( std::ios_base::badbit );
}
if ( !extracted )
err |= std::ios_base::failbit;
if ( err )
is.setstate( err );
return is;
}
///////////////////////////////////////////////////////////////////////////////
} // namespace zorba
#endif /* ZORBA_RSTRING_TCC */
/*
* Local variables:
* mode: c++
* End:
*/
/* vim:set et sw=2 ts=2: */
|
cc1d83b7c8802f2ad97af362748ae1804486827c
|
37695821fea740c507e60701a2781df027377212
|
/servicioPaginaError.cpp
|
6fa4017dce28b3a424359a75a5bc6c0247a6ef6c
|
[] |
no_license
|
rorra/phcp-cgi
|
25f16fbce411fb3c327a3bf4df9b26e398563a30
|
7588ba1c3f76c92a7509ffd2b7bc4e43519eae3c
|
refs/heads/master
| 1,611,257,304,869,430,000
| 1,347,884,902,000,000,000
| 1,347,884,902,000,000,000
| null | 0
| 0
| null | null | null | null |
ISO-8859-2
|
C++
| false
| false
| 11,129
|
cpp
|
servicioPaginaError.cpp
|
#include <string>
#include <mysql++.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fstream>
#include "dominio.h"
#include "util.h"
#include "servicio.h"
#include "servicioPaginaError.h"
#include "configuracion.h"
#include <errno.h>
using namespace std;
using namespace mysqlpp;
cServicioPaginaError::cServicioPaginaError(cDominio *dom):cServicio(dom) {
servicioDB = "PAGINAS ERROR";
}
bool cServicioPaginaError::iniciar() {
bool resultado = true;
cServicio::iniciar();
traerLimite();
traerCantidad();
if ((limite.length() <= 0) || (cantidad.length() <= 0))
resultado = false;
return(resultado);
}
int cServicioPaginaError::agregarFileHttpdConf(const std::string &codigo, cDominio &dominio) {
std::string archivo, archivo2, comando;
//Copiar el archivo de configuracion para parsearlo
archivo = "/usr/local/apache/conf/extra/httpd-vhosts.conf";
archivo2 = "/usr/local/apache/conf/extra/httpd-vhosts.conf.bak";
comando = "cp -f " + archivo + " " + archivo2;
if (system(comando.c_str()) < 0)
return(-1);
/* Abrir el archivo httpd-vhosts.conf para actualizar */
ofstream out(archivo.c_str());
if (!out.is_open()) {
comando = "No se pudo abrir el archivo " + archivo + " para las paginas de errores";
return(-1);
}
/* Abrir el archivo httpd-vhosts.conf.bak en modo lectura para parsear */
ifstream in(archivo2.c_str());
if (!in.is_open()) {
comando = "No se pudo abrir el archivo " + archivo2 + " para las paginas de errores";
return(-1);
}
std::string buscada, hasta, info;
//Llenar en buscada la cadena que se debe de buscar
buscada = "#################### Virtual Domain: www." + dominio.getDominio();
//Llenar en hasta la cadena donde se debe dejar de ignorar
hasta = "</VirtualHost>";
//Llenar en info la cadena que se debe agregar a la configuracion
info = "ErrorDocument " + codigo + " /errores/" + codigo + ".html";
//Parsear el archivo
char buffer[MINLINE];
std::string linea;
while (in.getline(buffer, MINLINE)) {
linea = buffer;
if (linea.find(buscada) != string::npos) {
while (linea.find(hasta) == string::npos) {
out << linea << endl;
in.getline(buffer, MINLINE);
linea = buffer;
}
out << info << endl;
}
out << linea << endl;
}
//Cerrar el archivo
out.close();
return(0);
}
int cServicioPaginaError::agregarFilePagina(const std::string &codigo, cDominio &dominio) {
std::string archivo, comando;
//Abrir el archivo para escritura
archivo = "/www/docs/" + dominio.getDominio() + "/public_html/errores/" + codigo + ".html";
ofstream out(archivo.c_str());
if (!out.is_open()) {
dominio.loguear("No se pudo abrir el archivo " + archivo);
return(-1);
}
//Agregar las linias
out << "<HTML>" << endl
<< "<HEAD>" << endl
<< "<TITLE>Pagina de error " << codigo << "</TITLE>" << endl
<< "</HEAD>" << endl
<< "<BODY>" << endl
<< "Aqui debe personalizar la página de error para el codigo " << codigo << "." << endl
<< "</BODY>" << endl
<< "</HTML>" << endl;
//Cerrar el archivo
out.close();
//Darle al directorio los permisos correspondientes
comando = "chown pdu" + dominio.getIdDominio() + ":pdu" + dominio.getIdDominio() + " " + "/www/docs/" + dominio.getDominio() + "/public_html/errores/";
system(comando.c_str());
//Darle al archivo los permisos correspondientes
comando = "chown pdu" + dominio.getIdDominio() + ":pdu" + dominio.getIdDominio() + " " + archivo;
system(comando.c_str());
return(0);
}
int cServicioPaginaError::agregarPaginaError(const std::string &codigo, cDominio &dominio) {
std::string comando, directorio;
//Obtener permisos de root
if (setuid(0) < 0) {
dominio.loguear("Error al obtener permisos de root");
return(-1);
}
//Si no existe crear el directorio para la pagina de error
directorio = "/www/docs/" + dominio.getDominio() + "/public_html/errores";
if (!existeDirectorio(directorio))
if (mkdir(directorio.c_str(), 0755))
if (errno != EEXIST) {
dominio.loguear("Error al crear el directorio de paginas de errores");
return(-1);
}
//Crear la pagina de error
if (agregarFilePagina(codigo, dominio) < 0) {
dominio.loguear("Error al crear la pagina de error para el codigo " + codigo);
return(-1);
}
//Agregar la pagina de error a la configuracion del apache
if (agregarFileHttpdConf(codigo, dominio) < 0) {
dominio.loguear("Error al agregar la pagina de error a la configuracion del apache");
return(-1);
}
return(0);
}
int cServicioPaginaError::agregarPaginaErrorDB(const std::string &codigo, cDominio &dominio) {
try {
Query qry = dominio.con.query();
qry << "INSERT INTO PAGINA_ERROR(CODIGO, ID_DOMINIO) VALUES('" << codigo << "', '"
<< dominio.getIdDominio() << "')";
qry.execute();
return(0);
} catch(BadQuery er) {
dominio.loguear(er.error);
return(-1);
} catch(...) {
string error;
error = "Error al agregar la pagina de error " + codigo;
dominio.loguear(error);
return(-2);
}
}
int cServicioPaginaError::quitarFileHttpdConf(const std::string &codigo, cDominio &dominio) {
std::string archivo, archivo2, comando;
//Copiar el archivo de configuracion para parsearlo
archivo = "/usr/local/apache/conf/extra/httpd-vhosts.conf";
archivo2 = "/usr/local/apache/conf/extra/httpd-vhosts.conf.bak";
comando = "cp -f " + archivo + " " + archivo2;
if (system(comando.c_str()) < 0)
return(-1);
/* Abrir el archivo httpd-vhosts.conf para actualizar */
ofstream out(archivo.c_str());
if (!out.is_open()) {
comando = "No se pudo abrir el archivo " + archivo + " para las paginas de errores";
return(-1);
}
/* Abrir el archivo httpd-vhosts.conf.bak en modo lectura para parsear */
ifstream in(archivo2.c_str());
if (!in.is_open()) {
comando = "No se pudo abrir el archivo " + archivo2 + " para las paginas de errores";
return(-1);
}
std::string buscada, hasta, info;
//Llenar en buscada la cadena que se debe de buscar
buscada = "#################### Virtual Domain: www." + dominio.getDominio();
//Llenar en hasta la cadena donde se debe dejar de ignorar
hasta = "</VirtualHost>";
//Llenar en info la cadena que se debe quitar a la configuracion
info = "ErrorDocument " + codigo + " /errores/" + codigo + ".html";
//Parsear el archivo
char buffer[MINLINE];
std::string linea;
while(in.getline(buffer, MINLINE)) {
linea = buffer;
if (linea.find(buscada) != string::npos) {
while (linea.find(hasta) == string::npos) {
if (linea.find(info) == string::npos)
out << linea << endl;
in.getline(buffer, MINLINE);
linea = buffer;
}
}
out << linea << endl;
}
//Cerrar el archivo
out.close();
return(0);
}
int cServicioPaginaError::quitarPaginaError(const std::string &codigo, cDominio &dominio) {
std::string comando, archivo;
//Obtener permisos de root
if (setuid(0) < 0) {
dominio.loguear("Error al obtener permisos de root");
return(-1);
}
//Eliminar el archivo que contiene la pagina de error
archivo = "/www/docs/" + dominio.getDominio () + "/public_html/errores/" + codigo + ".html";
unlink(archivo.c_str());
//Eliminar la pagina de error de la configuracion del apache
if (quitarFileHttpdConf(codigo, dominio) < 0) {
dominio.loguear("Error al quitar la pagina de error a la configuracion del apache");
return(-1);
}
//Verificar si existen paginas de error para el dominio
//si no existen hacer mierda el directorio
std::string dir = "/www/docs/" + dominio.getDominio() + "/public_html/errores";
if (!verificarExistenPaginaErrorDB(dominio))
if(existeDirectorio(dir)) {
comando = "rm -fr " + dir;
system(comando.c_str());
}
return(0);
}
int cServicioPaginaError::quitarPaginaErrorDB(const std::string &codigo, cDominio &dominio) {
try {
Query qry = dominio.con.query();
qry << "DELETE FROM PAGINA_ERROR WHERE CODIGO = '" << codigo << "' AND ID_DOMINIO = '"
<< dominio.getIdDominio() << "'";
qry.execute();
return(0);
} catch(BadQuery er) {
dominio.loguear(er.error);
return(-1);
} catch(...) {
string error;
error = "Error al quitar la pagina de error " + codigo;
dominio.loguear(error);
return(-2);
}
}
std::string cServicioPaginaError::traerCantidad() {
try {
Query qry = dominio->con.query();
qry << "SELECT COUNT(*) FROM PAGINA_ERROR WHERE ID_DOMINIO = '" << dominio->getIdDominio()
<< "'";
Result res = qry.store();
Row row;
Result::iterator i;
if (res.size() > 0) {
i = res.begin();
row = *i;
cantidad = std::string(row[0]);
}
return(cantidad);
} catch(BadQuery er) {
dominio->loguear(er.error);
return(cantidad);
} catch(...) {
string error;
error = "Error al recuperar la cantidad del servicio";
dominio->loguear(error);
return(cantidad);
}
}
int cServicioPaginaError::verificarExisteCodigoErrorDB(const std::string &codigo,
cDominio &dominio) {
int resultado = 0;
try {
Query qry = dominio.con.query();
qry << "SELECT COUNT(*) FROM DESCRIPCION_PAGINAS_ERROR WHERE CODIGO = '" << codigo << "'";
Result res = qry.store();
Row row;
Result::iterator i;
if (res.size() > 0) {
i = res.begin();
row = *i;
resultado = row[0];
}
return(resultado);
} catch(BadQuery er) {
dominio.loguear(er.error);
return(resultado);
} catch(...) {
string error;
error = "Error al verificar si existe la pagina de error " + codigo;
dominio.loguear(error);
return(resultado);
}
}
int cServicioPaginaError::verificarExistePaginaErrorDB(const std::string &codigo,
cDominio &dominio) {
int resultado = 0;
try {
Query qry = dominio.con.query();
qry << "SELECT COUNT(*) FROM PAGINA_ERROR WHERE CODIGO = '" << codigo << "' AND ID_DOMINIO = '" << dominio.getIdDominio() << "'" << endl;
Result res = qry.store();
Row row;
Result::iterator i;
if (res.size() > 0) {
i = res.begin();
row = *i;
resultado = row[0];
}
return(resultado);
} catch(BadQuery er) {
dominio.loguear(er.error);
return(resultado);
} catch(...) {
string error;
error = "Error al verificar si existe la pagina de error " + codigo;
dominio.loguear(error);
return(resultado);
}
}
int cServicioPaginaError::verificarExistenPaginaErrorDB(cDominio &dominio) {
int resultado = 0;
try {
Query qry = dominio.con.query();
qry << "SELECT COUNT(*) FROM PAGINA_ERROR WHERE ID_DOMINIO = '" << dominio.getIdDominio()
<< "'" << endl;
Result res = qry.store();
Row row;
Result::iterator i;
if (res.size() > 0) {
i = res.begin();
row = *i;
resultado = row[0];
}
return(resultado);
} catch(BadQuery er) {
dominio.loguear(er.error);
return(resultado);
} catch(...) {
string error;
error = "Error al verificar si existen paginas de errores";
dominio.loguear(error);
return(resultado);
}
}
|
faa632854d9d5d0ca59aff4a77539a8c2994d728
|
2ee1ea1154c57de6f7688215bf9dda49e0b15732
|
/src/87_hard_ScrambleString.cpp
|
643d982da2b60c7cb2be89ce2f644e30b8698b6a
|
[] |
no_license
|
FinixLei/leetcode_finix
|
0801e3f0b1cd4c0275e53ba758465f48ed89f7de
|
d29f6f8bb57671db44994055016f078afa509a80
|
refs/heads/master
| 1,678,160,988,769,433,000
| 1,676,863,447,000,000,000
| 1,676,863,447,000,000,000
| 44,184,923
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,744
|
cpp
|
87_hard_ScrambleString.cpp
|
/*
We can scramble a string s to get a string t using the following algorithm:
If the length of the string is 1, stop.
If the length of the string is > 1, do the following:
Split the string into two non-empty substrings at a random index, i.e., if the string is s, divide it to x and y where s = x + y.
Randomly decide to swap the two substrings or to keep them in the same order. i.e., after this step, s may become s = x + y or s = y + x.
Apply step 1 recursively on each of the two substrings x and y.
Given two strings s1 and s2 of the same length, return true if s2 is a scrambled string of s1, otherwise, return false.
Example 1:
Input: s1 = "great", s2 = "rgeat"
Output: true
Explanation: One possible scenario applied on s1 is:
"great" --> "gr/eat" // divide at random index.
"gr/eat" --> "gr/eat" // random decision is not to swap the two substrings and keep them in order.
"gr/eat" --> "g/r / e/at" // apply the same algorithm recursively on both substrings. divide at random index each of them.
"g/r / e/at" --> "r/g / e/at" // random decision was to swap the first substring and to keep the second substring in the same order.
"r/g / e/at" --> "r/g / e/ a/t" // again apply the algorithm recursively, divide "at" to "a/t".
"r/g / e/ a/t" --> "r/g / e/ a/t" // random decision is to keep both substrings in the same order.
The algorithm stops now, and the result string is "rgeat" which is s2.
As one possible scenario led s1 to be scrambled to s2, we return true.
Example 2:
Input: s1 = "abcde", s2 = "caebd"
Output: false
Example 3:
Input: s1 = "a", s2 = "a"
Output: true
*/
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;
unordered_map<string, bool> memo;
string genSortedString(string& s) {
int size = s.size();
if (size == 0 || size == 1) return s;
vector<char> array;
for (int i=0; i<size; i++) array.push_back(s[i]);
sort(array.begin(), array.end());
string result(array.begin(), array.end());
return result;
}
bool isScramble(string& s1, string& s2) {
if (s1.size() != s2.size()) return false;
if (s1.size() == 1) return s1 == s2;
string combined(s1);
combined.append(s2);
if (memo.find(combined) != memo.end()) return memo.at(combined);
int size = s1.size();
int part_length = 1;
while (part_length <= size/2) {
string s1_k1_p1 = s1.substr(0, part_length);
string s1_k1_p2 = s1.substr(part_length);
string s1_k2_p1 = s1.substr(size - part_length);
string s1_k2_p2 = s1.substr(0, size - part_length);
string s2_k1_p1 = s2.substr(0, part_length);
string s2_k1_p2 = s2.substr(part_length);
string s2_k2_p1 = s2.substr(size - part_length);
string s2_k2_p2 = s2.substr(0, size - part_length);
string sorted_s1_k1_p1 = genSortedString(s1_k1_p1);
string sorted_s1_k1_p2 = genSortedString(s1_k1_p2);
string sorted_s1_k2_p1 = genSortedString(s1_k2_p1);
string sorted_s1_k2_p2 = genSortedString(s1_k2_p2);
string sorted_s2_k1_p1 = genSortedString(s2_k1_p1);
string sorted_s2_k1_p2 = genSortedString(s2_k1_p2);
string sorted_s2_k2_p1 = genSortedString(s2_k2_p1);
string sorted_s2_k2_p2 = genSortedString(s2_k2_p2);
if (sorted_s1_k1_p1 == sorted_s2_k1_p1 && sorted_s1_k1_p2 == sorted_s2_k1_p2) {
if (isScramble(s1_k1_p1, s2_k1_p1) && isScramble(s1_k1_p2, s2_k1_p2)) {
return true;
}
}
if (sorted_s1_k2_p1 == sorted_s2_k1_p1 && sorted_s1_k2_p2 == sorted_s2_k1_p2) {
if (isScramble(s1_k2_p1, s2_k1_p1) && isScramble(s1_k2_p2, s2_k1_p2)) {
return true;
}
}
if (sorted_s1_k1_p1 == sorted_s2_k2_p1 && sorted_s1_k1_p2 == sorted_s2_k2_p2) {
if (isScramble(s1_k1_p1, s2_k2_p1) && isScramble(s1_k1_p2, s2_k2_p2)) {
return true;
}
}
if (sorted_s1_k2_p1 == sorted_s2_k2_p1 && sorted_s1_k2_p2 == sorted_s2_k2_p2) {
if (isScramble(s1_k2_p1, s2_k2_p1) && isScramble(s1_k2_p2, s2_k2_p2)) {
return true;
}
}
part_length ++;
}
memo[combined] = false;
return false;
}
int main()
{
string s1 = "eebaacbcbcadaaedceaaacadccd";
string s2 = "eadcaacabaddaceacbceaabeccd";
bool result = isScramble(s1, s2);
cout << "result = " << result << endl;
return 0;
}
|
327826d7e2a15dd0594ba67f643fa21cbf15e799
|
ca84490c8fe9c5ee77f3abf5ffad9379b95a0abb
|
/2018.10/2018.10.31/force2.cpp
|
d258555fc31bb7c3afceb10b7fc19d4fa0dafb29
|
[
"ICU",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
LoganJoe/training-data
|
1df9dc6ef730f6c6a0130f50caed19556f5e1f87
|
b77b8e7271dcb73ce96c5236c433ce557e0e16f0
|
refs/heads/master
| 1,635,218,264,883,996,000
| 1,554,878,341,000,000,000
| 1,554,878,341,000,000,000
| 178,348,836
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,759
|
cpp
|
force2.cpp
|
#include<bits/stdc++.h>
#define N 1000005
#define mod 998244353
int Case,n,head[N],ecnt,k,A[N],mark[N],f[N],ans,fac[N];
int fa[N][20],val[N][20],deep[N];
struct edge{int v,w,next;}e[N<<1];
void add(int u,int v,int w){e[++ecnt]={v,w,head[u]};head[u]=ecnt;}
int mul(int x){return x>=mod?x-mod:x;}
int Pow(int x,int k){int t=1;for(;k;k>>=1,x=1ll*x*x%mod) if(k&1) t=1ll*t*x%mod;return t;}
void dfs(int u,int fath)
{
fa[u][0]=fath;deep[u]=deep[fath]+1;
for(int i=head[u];i;i=e[i].next)
{
int v=e[i].v;
if(v==fath) continue;
val[v][0]=e[i].w;
dfs(v,u);
}
}
void process()
{
for(int j=1;j<20;j++)
for(int i=1;i<=n;i++)
fa[i][j]=fa[fa[i][j-1]][j-1],val[i][j]=mul(val[i][j-1]+val[fa[i][j-1]][j-1]);
}
int askdist(int u,int v)
{
int res=0;
if(deep[u]<deep[v]) std::swap(u,v);
for(int i=19;~i;i--) if(deep[fa[u][i]]>=deep[v]) res=mul(res+val[u][i]),u=fa[u][i];
if(u==v) return res;
for(int i=19;~i;i--)
if(fa[u][i]!=fa[v][i]) res=(res+val[u][i]+val[v][i])%mod,u=fa[u][i],v=fa[v][i];
res=mul(res+val[u][0]+val[v][0]);
return res;
}
int main()
{
freopen("path.in","r",stdin);
freopen("path.ans","w",stdout);
fac[0]=1;
for(int i=1;i<N;i++) fac[i]=1ll*fac[i-1]*i%mod;
scanf("%d",&Case);
scanf("%d",&n);
for(int i=1,u,v,w;i<n;i++) scanf("%d%d%d",&u,&v,&w),add(u,v,w),add(v,u,w);
scanf("%d",&k);
for(int i=1;i<=k;i++) scanf("%d",&A[i]),mark[A[i]]=1;
dfs(1,0);
process();
for(int i=1;i<=k;i++) f[i]=i;
do
{
int res=0;
for(int i=1;i<k;i++) res=mul(res+askdist(A[f[i]],A[f[i+1]]));
//for(int i=1;i<k;i++) printf("%d ",askdist(A[f[i]],A[f[i+1]]));
//for(int i=1;i<=k;i++) printf("%d ",A[f[i]]);
//printf("%d\n",res);
ans=mul(ans+res);
}while(std::next_permutation(f+1,f+1+k));
printf("%d\n",1ll*ans*Pow(fac[k],mod-2)%mod);
}
|
4f46ffa86fc4d5e364249ccb80ea2f7d7e91624a
|
87d69ded7629a54220ceefcdf21449acf6a0d5a0
|
/lib/src/Engine.cpp
|
5f952878c1cafb0bd2b59e952916646492571f28
|
[
"Apache-2.0"
] |
permissive
|
F4r3n/FarenMediaLibrary
|
955e63f3c94bae9a0245cbfa2a2e0ff49c5d915d
|
a138ea5ec687e7252b63d5cb1bdbc06be02961aa
|
refs/heads/main
| 1,691,526,327,094,533,000
| 1,691,413,015,000,000,000
| 1,691,413,015,000,000,000
| 65,391,951
| 8
| 1
|
Apache-2.0
| 1,692,113,844,000,000,000
| 1,470,841,366,000,000,000
|
C
|
UTF-8
|
C++
| false
| false
| 2,411
|
cpp
|
Engine.cpp
|
#include <ECS.h>
#include "Engine.h"
#include <Window.h>
#include <TimeDef.h>
#include "Physic/PhysicSystem.h"
#include "Rendering/RenderingSystem.h"
#include "Script/ScriptManagerSystem.h"
#include "Music/SoundSystem.h"
#include "Profiler/Profile.hpp"
#include "Profiler/Profiler.hpp"
#include "Profiler/ProfilerMacro.h"
#include "Core/Config.h"
#include "Core/GameObject.h"
#include "Physic/PhysicSystem.h"
#include "Components/cevent.hpp"
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
#include "Components/CIdentity.h"
using namespace fm;
class GarbageCollector
{
public:
static void Collect()
{
for (auto && e : EntityManager::get().iterate<fmc::CEvent>())
{
fmc::CEvent* event = e.get<fmc::CEvent>();
event->Clear();
}
}
};
Engine::Engine()
{
_systems = std::unique_ptr<SystemManager>(new SystemManager());
}
Engine::~Engine()
{
EntityManager::get().Free();
}
void Engine::Start()
{
_systems->Start();
}
SYSTEM_MANAGER_MODE Engine::GetStatus() const
{
return _systems->GetStatus();
}
void Engine::Init()
{
_systems->addSystem(new fms::SoundSystem());
_systems->addSystem(new fms::PhysicSystem());
_systems->addSystem(new fms::ScriptManagerSystem());
_systems->addSystem(new fms::RenderingSystem(fm::Window::kWidth, fm::Window::kHeight));
_systems->init(EntityManager::get(), EventManager::Get());
}
void Engine::Stop()
{
_systems->Stop();
}
void Engine::Resume()
{
fm::Time::scale = 1;
}
void Engine::Reset()
{
_systems->addSystem(new fms::ScriptManagerSystem());
}
void Engine::Update(float dt)
{
// auto start = std::chrono::system_clock::now();
_systems->update(dt * Time::scale, EntityManager::get(), EventManager::Get());
GarbageCollector::Collect();
//_numberFramesTimer++;
//if(_numberFramesTimer == 200) {
// auto end = std::chrono::system_clock::now();
// auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
// float time = elapsed.count();
// start = end;
// std::cout << "Time per frame " << time << " ms" << std::endl;
// _numberFramesTimer = 0;
//}
}
bool fm::IsEntityActive(EntityManager& em, const Entity::Id& id)
{
Entity e = em.GetEntity(id);
fmc::CIdentity* identity = e.get<fmc::CIdentity>();
if (identity != nullptr && identity->IsActive())
return true;
if (identity == nullptr)
return true;
return false;
}
|
3737af13e80849aa7794736b20663d62999e9c4d
|
1186e892a29f85d653379c5b87b04736dbb8b1fb
|
/Contests/2021 April Long Challenge/Programs/World Record.cpp
|
6cd55606dd02a0f6d36b4a85e75e6a44cddd10d3
|
[] |
no_license
|
MathProgrammer/CodeChef
|
1f4a2963cf60b3386861f1935b1642580f595c32
|
b9750e56ee6e307e5f60a43d7682105fd99fcf1b
|
refs/heads/master
| 1,683,734,759,958,225,000
| 1,683,379,033,000,000,000
| 1,683,379,033,000,000,000
| 88,233,956
| 22
| 23
| null | 1,601,710,716,000,000,000
| 1,492,145,444,000,000,000
|
C++
|
UTF-8
|
C++
| false
| false
| 468
|
cpp
|
World Record.cpp
|
#include <iostream>
#include <cmath>
using namespace std;
void solve()
{
double k1, k2, k3, v;
cin >> k1 >> k2 >> k3 >> v;
const int DISTANCE = 100,RECORD = 958;
double speed = k1*k2*k3*v;
int time = round(100*DISTANCE/speed);
cout << (time < RECORD ? "Yes" : "No") << "\n";
}
int main()
{
int no_of_test_cases;
cin >> no_of_test_cases;
while(no_of_test_cases--)
solve();
return 0;
}
|
3e89d1d5a1ffb829fd540a80e809b826bfa48453
|
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
|
/trunk/nGENE Proj/FileArchive.h
|
6d300f8381c1db14d587362031336e3f20794050
|
[] |
no_license
|
svn2github/ngene
|
b2cddacf7ec035aa681d5b8989feab3383dac012
|
61850134a354816161859fe86c2907c8e73dc113
|
refs/heads/master
| 1,693,744,458,944,872,000
| 1,311,794,764,000,000,000
| 1,311,794,764,000,000,000
| 78,163,390
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,626
|
h
|
FileArchive.h
|
/*
---------------------------------------------------------------------------
This source file is part of nGENE Tech.
Copyright (c) 2006- Wojciech Toman
This program is free software.
File: FileArchive.h
Version: 0.01
---------------------------------------------------------------------------
*/
#pragma once
#ifndef __INC_FILEARCHIVE_H_
#define __INC_FILEARCHIVE_H_
#include "FileManager.h"
#include "FileNarrow.h"
#include "Prerequisities.h"
namespace nGENE
{
/** This file class provides VFS functionality.
@remarks
It is base class.
*/
class nGENEDLL FileArchive: public FileNarrow
{
public:
FileArchive();
/** Constructs the File and opens it.
@param
_fileName wide char file name.
@param
_openMode combination of flags of OPEN_MODE type. You
can combine any of them.
*/
FileArchive(const wstring& _fileName, dword _openMode);
/// Copy constructor.
FileArchive(const FileArchive& src);
/// Closes and than releases wfstream.
virtual ~FileArchive();
/// Assignment operator.
FileArchive& operator=(const FileArchive& rhs);
/// Returns entry with the given name.
virtual VFS_ENTRY* getEntry(const string& _fileName)=0;
/// Checks if a specified entry exists in the archive.
virtual bool hasEntry(const string& _fileName)=0;
/// Inserts file to the archive when opened in OPEN_WRITE mode.
virtual void insertFile(IFile* _file)=0;
/// Initializes archive file.
virtual void init()=0;
/// Returns number of files in the archive
virtual uint getEntriesCount()=0;
};
}
#endif
|
76ec3af2b117bb247b76911303f557a0dacb29f3
|
ffa04f08be79ad3c59d05193eb4d5f796108a347
|
/src/terrain_generator.cpp
|
505140152bd3b0ad2356f860ba676536059be1a1
|
[] |
no_license
|
sashman/terrain_generator
|
a52954b2773667a4702614067e4d01f126bbb0fe
|
4ec16c8b20e74b3f89222f2e879a6d4814b50b1c
|
refs/heads/master
| 1,611,544,824,393,865,000
| 1,404,754,858,000,000,000
| 1,404,754,858,000,000,000
| 2,606,735
| 4
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 14,272
|
cpp
|
terrain_generator.cpp
|
//============================================================================
// Name : terrain_generator.cpp
// Author : sash
//============================================================================
#include "terrain_generator.hpp"
//Only using STANDARD_HEIGHTS
//this is then used by output format to eventually create json maps
enum OUTPUT_FORMAT
{
STANDRARD_HEIGHTS, STANDARD_XML, OPENGL_VIEW
};
OUTPUT_FORMAT output_format = STANDRARD_HEIGHTS;
//Whether to display verbose messages.
int verbose = 0;
std::string output_file = DEAFULT_TERRAIN_FILE;
std::string config_file = DEFAULT_CONFIG_FILE;
//the main array that holds the height map data
extern int** tmap;
//properties of the height map
//the height map must be generated as a square of sides equal to (a power of 2) + 1
extern int tmap_size;
//the crop height/width is then used to crop it to the requested size
extern int crop_height;
extern int crop_width;
//store the random, TODO: allow for the user to provide the seed
int random_seed = 0;
//used to determine the relative size of 1 pixel to the output
//not used
int scale = 1;
//for more explanation on the below values see Midpoint displacement algorithm (http://www.gameprogrammer.com/fractal.html)
//the starting point of the corners of the height map
extern int seed;
//the max value of the next offset
extern int random_offset;
//the "roughness" value, the change in random_offset for the next iteration
extern float offset_dr;
//number of voronoi points to be used
extern int voronoi_size;
//the fraction used as the strength of the voronoi values, when interpolating with the height map
extern float voronoi_alpha;
//number of times the height map should be eroded
extern int erosion_steps;
//true if allowing for negative values
extern bool neg;
//noramlise the height map between the given max and min value
extern bool normalise;
extern int normalise_min;
extern int normalise_max;
//height levels of different terrain types
extern int sea_level;
extern int sand_level;
extern int snow_level;
extern int cliff_difference;
//max number of rivers
extern int n_rivers;
//number of times a river can produce a branch
extern int max_branches;
//max number of settlements
extern int n_settlements;
//minimum distance between two settlements
extern int min_distance;
//max number of vegetation units
extern int n_vegetation;
//the areas around a unit of vegetation which can influence it, used for water (maybe?) and spawning new vegetation
extern int root_radius;
//number of iteration for which spawn new vegetation units based on the existing units
extern int generations;
//TODO: Update usage string
void print_usage(FILE* stream, int exit_code, char* program_name)
{
fprintf(stream,
"A program to generate terrain and features with variable formats.\n\n");
fprintf(stream, "Usage: %s [options]\n", program_name);
fprintf(stream,
" -h --help Display this usage information.\n"
" -c --config <filename> Use custom config file.\n"
" -v --verbose Print verbose messages.\n"
" --height <value> Crop the map down to specified positive integer height.\n"
" --width <value> Crop the map down to specified positive integer width.\n"
" --rough <value> Define smoothness of the terrain as a float (0.0 < v < 1.0).\n"
" Lower values produce smoother terrain, smaller difference in adjacent tiles.\n"
" --seed <value> Set the initial positive integer height for the algorithm to be generate values from.\n"
" --offset <value> Set the initial offset positive integer height (seed+offset=max possible height).\n"
" --plate <value> Set the fraction of the tectonic plates appearance.\n"
" Higher values will give a more 'ripped apart' look, values too close to 1 are not\n"
" recommended for realistic terrain. (0.0 < v < 1.0)\n"
" --erosion <value> Number of erosion iterations over the terrain. Must be a positive integer.\n"
" -n --negative Allow for negative height values.\n"
" -s --standard Use standard output to be written to a file (used as default output).\n"
" width, height and a set of height values all separated by a space.\n"
" -g --graphical Display the height map using a 3D OpenGL view.\n"
" -x --xml Use the following xml output to be written to a file:\n"
" <map width=int height=int>\n"
" [<tile x=int y=int>\n"
" <height>int</height>\n"
" <type>string</type>\n"
" </tile>\n]+"
" </map>\n");
exit(exit_code);
}
//helper method used to return a string of the file contents
std::string get_file_contents(const char *filename)
{
std::ifstream in(filename, std::ios::in | std::ios::binary);
if (in)
{
std::string contents;
in.seekg(0, std::ios::end);
contents.resize(in.tellg());
in.seekg(0, std::ios::beg);
in.read(&contents[0], contents.size());
in.close();
return (contents);
}
throw(errno);
}
//using a set filename, read the contents of the config file and set the values
void read_json_config()
{
std::string json = get_file_contents(config_file.c_str());
rapidjson::Document d;
d.Parse<0>(json.c_str());
output_file = d["output_file"].GetString();
crop_width = d["height"].GetInt();
crop_height = d["width"].GetInt();
scale = d["scale"].GetInt();
seed = d["seed"].GetInt();
random_offset = d["offset"].GetInt();
offset_dr = d["rough"].GetDouble();
normalise = (strcmp(d["normalise"].GetString(), "true") == 0);
normalise_min = d["normalise_min"].GetInt();
normalise_max = d["normalise_max"].GetInt();
sea_level = d["sea_level"].GetInt();
sand_level = d["sand_level"].GetInt();
snow_level = d["snow_level"].GetInt();
cliff_difference = d["cliff_height_difference"].GetInt();
n_rivers = d["number_of_river_sources"].GetInt();
max_branches = d["max_branches_per_source"].GetInt();
n_settlements = d["number_of_settlements"].GetInt();
min_distance = d["min_distance_between_settlements"].GetInt();
n_vegetation = d["number_of_vegetation"].GetInt();
root_radius = d["vegetation_root_radius"].GetInt();
generations = d["vegetation_generations"].GetInt();
}
//TODO:
//TODO: Use libnoise http://libnoise.sourceforge.net/tutorials/index.html !!!
//TODO:
void generate()
{
//set crop height and width
if (crop_height < 1)
crop_height = tmap_size;
if (crop_width < 1)
crop_width = tmap_size;
//if a crop value is set
//set tmap_size to fit the cropped values
int max_size = std::max(crop_height, crop_width);
int max_size_tmp = max_size - 1;
if ((max_size_tmp & (max_size_tmp - 1)) == 0)
{
//leave set size as highest crop value
tmap_size = max_size;
}
else
{
//find smallest value such that (value is power of 2) + 1 and value > max_size
int t = ceil(log2(max_size)) + 1;
tmap_size = (1 << t) + 1;
}
double finish = 0;
//display info
if (verbose)
{
std::cout << "Using " << config_file << std::endl;
std::cout << "Staring square diamond" << std::endl;
std::cout << "Size: " << crop_width << " x " << crop_height
<< " original size " << tmap_size << std::endl;
std::cout << "Starting seed value " << seed << std::endl;
std::cout << "Starting random offset " << random_offset << std::endl;
std::cout << "Random offset decrease ratio " << offset_dr << std::endl;
}
//init map array
tmap = new int*[tmap_size];
for (int i = 0; i < tmap_size; ++i)
{
tmap[i] = new int[tmap_size];
for (int j = 0; j < tmap_size; j++)
tmap[i][j] = 0;
}
// initialize random seed:
// use for generating a random map every time
// srand ( time(NULL) );
//harcoded for now as produces a nice map for testing
srand(12);
//fill the array with values
square_diamond();
//interpolate voronoi diagram
//TODO: add noise to voronoi
if (verbose)
{
std::cout << "Voronoi points " << voronoi_size << std::endl;
/*
for (int i = 0; i < voronoi_size; ++i) {
std::cout << "\t" << voronoi_points[i][0] << "," << voronoi_points[i][1] << std::endl;
}
*/
}
voronoi();
erosion();
if (!neg)
clear_neg();
// finish = clock() - start;
if (verbose)
std::cout << "Finished square diamond " << (finish / 1000000)
<< std::endl;
double sqadia = (finish / 1000000);
if (normalise)
{
if (verbose)
std::cout << "Normalising with value range " << normalise_min << "-"
<< normalise_max << std::endl;
normalise_map();
}
if (output_format == STANDRARD_HEIGHTS)
{
print_map(fopen(output_file.c_str(), "w"));
}
else if (output_format == STANDARD_XML)
{
print_map_xml(fopen(output_file.c_str(), "w"));
}
if (scale > 0 && crop_height > 256 && crop_width > 256)
{
// start = clock();
if (verbose)
std::cout << "Generating rivers" << std::endl;
rivers();
// finish = clock() - start;
if (verbose)
std::cout << "Done " << (finish / 1000000) << std::endl;
double rivers_time = (finish / 1000000);
print_rivers(0);
// start = clock();
if (verbose)
std::cout << "Generating vegetation" << std::endl;
vegetation(verbose);
// finish = clock() - start;
if (verbose)
std::cout << "Done " << (finish / 1000000) << std::endl;
double veg_time = (finish / 1000000);
print_vegetation(0);
if (verbose)
std::cout << "Generating settlements" << std::endl;
settlements();
// finish = clock() - start;
if (verbose)
std::cout << "Done " << (finish / 1000000) << std::endl;
double settlement_time = (finish / 1000000);
print_settlements(0);
std::cout << crop_height << "\t"
<< (sqadia + rivers_time + veg_time + settlement_time) << "\t"
<< sqadia << "\t " << rivers_time << "\t" << veg_time << "\t"
<< settlement_time << std::endl;
}
std::cout << "Drawing contours" << std::endl;
contour_map(32, 32, verbose);
print_contour(0);
print_kf(0);
}
int main(int argc, char** argv)
{
int next_option;
/* A string listing valid short options letters. */
const char* const short_options = "hc:sxgvna:";
/* An array describing valid long options. */
const struct option long_options[] =
{
{ "help", 0, NULL, 'h' },
{ "config", 1, NULL, 'c' },
{ "standard", 0, NULL, 's' },
{ "xml", 0, NULL, 'x' },
{ "graphic", 0, NULL, 'g' },
{ "verbose", 0, NULL, 'v' },
{ "height", 1, NULL, 'e' },
{ "width", 1, NULL, 'w' },
{ "rough", 1, NULL, 'r' },
{ "seed", 1, NULL, 'd' },
{ "offset", 1, NULL, 'f' },
{ "plate", 1, NULL, 'p' },
{ "erosion", 1, NULL, 'o' },
{ "negative", 0, NULL, 'n' },
{ "randomseed", 1, NULL, 'a' },
{ NULL, 0, NULL, 0 } /* Required at end of array. */
};
/* Remember the name of the program, to incorporate in messages.
The name is stored in argv[0]. */
char* program_name = argv[0];
if (fopen(config_file.c_str(), "r"))
read_json_config();
do
{
next_option = getopt_long(argc, argv, short_options, long_options,
NULL);
switch (next_option)
{
case 'h': /* -h or --help */
/* User has requested usage information. Print it to standard
output, and exit with exit code zero (normal termination). */
print_usage(stdout, 0, program_name);
break;
case 'c': //config file
if(strcmp(config_file.c_str(),optarg) != 0)
{
config_file = optarg;
read_json_config();
}
break;
case 's': /* -s --standard */
//Use default output format
//do nothing
break;
case 'x': /* -x --xml*/
//Use xml output format
output_format = STANDARD_XML;
break;
case 'g': /* -g --graphical*/
//Display the map as 3d opengl representation
output_format = OPENGL_VIEW;
break;
case 'v': /* -v or --verbose */
verbose = 1;
break;
case 'e': /* --height use next argument as crop height */
crop_height = atoi(optarg);
if(crop_height < 1)
print_usage(stderr, 1, program_name);
break;
case 'w': /* --width use next argument as crop width */
crop_width = atoi(optarg);
if(crop_width < 1)
print_usage(stderr, 1, program_name);
break;
case 'r': /* --rough roughness ratio */
offset_dr = atof(optarg);
if(offset_dr<0 || offset_dr>1)
{
print_usage(stderr, 1, program_name);
}
break;
case 'd': /* --seed value */
seed = atoi(optarg);
if(seed<0)
print_usage(stderr, 1, program_name);
break;
case 'f': /* --offset value */
random_offset = atoi(optarg);
if(random_offset<0)
print_usage(stderr, 1, program_name);
break;
case 'p': /* --plate vonornoi interpolation value */
voronoi_alpha = atof(optarg);
if(voronoi_alpha<0 || voronoi_alpha>1)
{
print_usage(stderr, 1, program_name);
}
break;
case 'o': /* --erosion number of erosion iterations */
erosion_steps = atoi(optarg);
if(erosion_steps<0)
print_usage(stderr, 1, program_name);
break;
case 'n': /* allow negative values */
neg = true;
break;
case 'a': /* random seed value */
// srand ( time(NULL) );
break;
case '?': /* The user specified an invalid option. */
/* Print usage information to standard error, and exit with exit
code one (indicating abnormal termination). */
print_usage(stderr, 1, program_name);
break;
case -1: /* Done with options. */
break;
default: /* Something else: unexpected. */
abort();
break;
}
} while (next_option != -1);
generate();
return 0;
}
|
c1c663377ddeb8ff0a5a23518df4831b05a39eb5
|
0f882dfb4b18a007898fdaae26b9d073f3bdfe07
|
/1062a.cpp
|
f3b640e5486f03081f8ba3323237a7765c7107eb
|
[] |
no_license
|
samael65535/my_hdoj_code
|
76898165b7da1351828808f0ec2b1d08521c1b30
|
43f508e5fb152ba582aff2590d0d865fac33a041
|
refs/heads/master
| 1,609,532,268,840,440,000
| 1,367,642,423,000,000,000
| 1,367,642,423,000,000,000
| 2,841,816
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 473
|
cpp
|
1062a.cpp
|
#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
int t;
cin>>t;
getchar();
while(t--)
{
char a[1001];
cin.getline(a,1001);
int n=strlen(a);
for(int i=0;i<n;i++)
{
int k=i;
while(a[k]!=' '&&a[k]!='\0') k++;
for(int j=k-1;j>=i;j--)
cout<<a[j]; i=k;
if(a[i]==' ') cout<<' ';
}
cout<<endl;
}
}
|
401faa132e0cf3c6e19b420cb905f56b6b1ace1e
|
1cd703a3e8113f7f415a0d8a261ee492a76f8331
|
/Src/Coord3D/Tr3D.cpp
|
1934a4fe7464c2d74097af232c810c59b45a846f
|
[] |
no_license
|
Nocturne-hub/IG
|
6d2ec6167fda09df8f39adda84161bbb106fce8d
|
9bd7660494fe615dd98c8ea0ca186afa53c7f393
|
refs/heads/master
| 1,681,962,326,679,138,000
| 1,620,678,201,000,000,000
| 1,620,678,201,000,000,000
| 350,336,455
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 196
|
cpp
|
Tr3D.cpp
|
#include "Tr3D.h"
Tr3D::Tr3D(float tx, float ty, float tz)
: TG3D()
{
mat[0][3] = tx;
mat[1][3] = ty;
mat[2][3] = tz;
}
Tr3D::Tr3D(const Dir3D& dir)
: Tr3D(dir.x, dir.y, dir.z){}
|
33ba1a03b6747d31428dfa90d34b4d16d5ad43fe
|
366b754ca6d2ccb76fad4736c750ff15eb92fa15
|
/Nero_Frogger/Source/Observer.h
|
5b04c57fe61ae5be262bb4da454955d02ec5c932
|
[] |
no_license
|
ellePAZ/Frogger-clone
|
19d40a32ce121d0e11e84a7ebd9402770f21b722
|
b2b20e42ed9f84633ea3c60ed7a95818d089ac68
|
refs/heads/main
| 1,688,528,897,886,237,000
| 1,628,672,462,000,000,000
| 1,628,672,462,000,000,000
| 394,924,833
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 234
|
h
|
Observer.h
|
#pragma once
#include "Entity.h"
#include "Event.h"
#include <iostream>
class Observer
{
public:
Observer();
virtual ~Observer();
virtual void onNotify(Entity* entity, Event event) = 0;
virtual void onNotify(Event event) = 0;
};
|
42e6affcf632069a6f9c62cfbc2835514e4ea7ea
|
b2f3d0cadf4e399a9ea1e722fb6b066fb2623dfd
|
/Dynamic Programming/EditDistance/EditDistanceBottomUp.cpp
|
bf006b4875afb0a0c595d3a4ff7d5d17de206cb1
|
[] |
no_license
|
Surbhi-Kohli/DSandAlgo
|
ade89afa3840ca7374f34bc600890003c3b4df5f
|
6b539af12b08e9016373ef6bbe6b10022c238eaa
|
refs/heads/master
| 1,624,827,727,158,580,000
| 1,615,210,747,000,000,000
| 1,615,210,747,000,000,000
| 218,819,088
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 948
|
cpp
|
EditDistanceBottomUp.cpp
|
/* Time Complexity: O(m x n)
Auxiliary Space: O(m x n) */
#include <iostream>
#include <cstring>
using namespace std;
int editDistance(string s1,string s2,int m,int n)
{
int dp[m+1][n+1];
memset(dp,0,sizeof dp);
for(int i=0;i<=m;i++)
{
for(int j=0;j<=n;j++)
{
if(i==0)
dp[i][j]=j;
else if(j==0)
dp[i][j]=i;
else if(s1[i-1]==s2[j-1])
{
dp[i][j]=dp[i-1][j-1];
}
else{
dp[i][j]=1+min(min(dp[i][j-1],dp[i-1][j]),dp[i-1][j-1]);
}
}
}
for(int i=0;i<=m;i++)
{
for(int j=0;j<=n;j++)
{
cout<<dp[i][j]<<" ";
}
cout<<endl;
}
return dp[m][n];
}
int main() {
// your code goes here
string s1,s2;
cin>>s1>>s2;
int m,n;
m=s1.length();
n=s2.length();
cout<<editDistance(s1,s2,m,n);
return 0;
}
|
9d3f4fc2353d68d9e46ad609676051b513e1a4af
|
87e9cbdc0f0cab9b997e5e3bd331bce4021afbfc
|
/mainwindow.h
|
d04efa6b921ef9aee7003cf8db4df42c046e2c1a
|
[] |
no_license
|
quentin-pla/Projet-Courbes-Surfaces-3D
|
5e52e8844e9bf04065360ed3c15af093b523aa4c
|
52ae7c218d589110af2b94ac5b4e062c9f18e51e
|
refs/heads/master
| 1,678,750,049,914,185,000
| 1,616,186,429,000,000,000
| 1,616,186,429,000,000,000
| 346,024,824
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 764
|
h
|
mainwindow.h
|
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "point.h"
namespace Ui {
class MainWindow;
}
/**
* Fenêtre principale
*/
class MainWindow : public QMainWindow {
Q_OBJECT
public:
/**
* Constructeur
* @param parent parent
*/
explicit MainWindow(QWidget *parent = 0);
/**
* Destructeur
*/
~MainWindow() override;
protected slots:
/**
* Mettre à jour les coordonnées du point de l'UI
*/
void onUpdateUIPointCoords(Point *point);
/**
* À la sauvegarde d'un fichier OBJ
* @param data
*/
void onSaveOBJFile(const std::stringstream &data);
private:
/**
* Interface utilisateur
*/
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
|
45377cb7287b617404c09bfb8ee51f88d161f4ec
|
e8127d7a089d4939266c4a5f3a5a91b771efec56
|
/1. Arrays/Intermidiate/19.cpp
|
4d979b116854f31cad5bba23feef9fbf5252f2ed
|
[] |
no_license
|
NeelParihar/DS-ALGO
|
9581111d1203b972d161a2b6f28ee497b1e141e5
|
ef1083fd94be05d48b0c654ea41130d6fdac01b1
|
refs/heads/master
| 1,658,169,322,237,749,000
| 1,590,421,939,000,000,000
| 1,590,421,939,000,000,000
| 262,999,528
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 510
|
cpp
|
19.cpp
|
// 19. GCD of given index ranges in an array
#include<iostream>
using namespace std;
int gcd(int a,int b)
{
if(b==0)
{
return a;
}
return(gcd(b,a%b));
}
int main()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
int q;
cin>>q;
while(q--)
{
int l,r;
cin>>l>>r;
int result=arr[l];
for(int i=l+1;i<=r;i++)
{
result = gcd(arr[i],result);
}
cout<<result<<endl;
}
return(0);
}
|
2c3979ac22df632b37794da8c86624acaeb410f0
|
6c2aba71a9ab03ad57b9d1efed7b94335abea348
|
/Source/SoFRemastered/SoFRemastered.cpp
|
0a770514c3177701265a598df85b25bd56d9c210
|
[] |
no_license
|
Keithpohl82/FPS_Code
|
3d36a1559ab21cbf4a9de44515edf074cc909abd
|
008ef16c9f37817d2f7b36abd013c70bb357103a
|
refs/heads/master
| 1,670,030,359,972,894,000
| 1,598,137,374,000,000,000
| 1,598,137,374,000,000,000
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 210
|
cpp
|
SoFRemastered.cpp
|
// Copyright Epic Games, Inc. All Rights Reserved.
#include "SoFRemastered.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, SoFRemastered, "SoFRemastered" );
|
c3fdf11399b5fe09a099c85b942c14393c38319b
|
463ccbc7b19822e3695e02d27e255ce64eacb627
|
/ie3D-Core/Sources/CMaterial.h
|
0285c276aa56cf0e0e7a404ad1cd6cdc7bc046df
|
[] |
no_license
|
codeoneclick/ie3D
|
8abd318361ff80fbbfe5273943183fe158bf40af
|
46f109a520c6d813c3994b5cf2b12e2de5625371
|
refs/heads/master
| 1,611,470,261,615,380,000
| 1,400,853,732,000,000,000
| 1,400,853,732,000,000,000
| 9,913,979
| 10
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,007
|
h
|
CMaterial.h
|
//
// CMaterial.h
// indie2dEngine
//
// Created by Sergey Sergeev on 5/17/13.
// Copyright (c) 2013 Sergey Sergeev. All rights reserved.
//
#ifndef CMaterial_h
#define CMaterial_h
#include "HCommon.h"
#include "HEnums.h"
#include "HDeclaration.h"
class CMaterialCachedParameters
{
private:
friend class CMaterial;
protected:
bool m_isCulling;
GLenum m_cullingMode;
bool m_isBlending;
GLenum m_blendingFunctionSource;
GLenum m_blendingFunctionDestination;
bool m_isDepthTest;
bool m_isDepthMask;
bool m_isClipping;
glm::vec4 m_clippingPlane;
bool m_isReflecting;
bool m_isShadowing;
bool m_isDebugging;
CSharedShader m_shader;
std::array<CSharedTexture, E_SHADER_SAMPLER_MAX> m_textures;
public:
CMaterialCachedParameters(void);
~CMaterialCachedParameters(void);
};
class CMaterial
{
private:
protected:
CSharedMaterialCachedParameters m_parameters;
static CSharedMaterialCachedParameters m_cachedParameters;
static CSharedMaterialCachedParameters getCachedParameters(void);
public:
CMaterial(void);
~CMaterial(void);
static void setupMaterial(CSharedMaterialRef material,
CSharedConfigurationMaterialRef configuration,
CSharedResourceAccessor resourceAccessor,
ISharedScreenSpaceTextureAccessor screenSpaceTextureAccessor,
ISharedResourceLoadingHandlerRef handler = nullptr);
bool isCulling(void) const;
GLenum getCullingMode(void) const;
bool isBlending(void) const;
GLenum getBlendingFunctionSource(void) const;
GLenum getBlendingFunctionDestination(void) const;
bool isDepthTest(void) const;
bool isDepthMask(void) const;
bool isClipping(void) const;
glm::vec4 getClippingPlane(void) const;
bool isReflecting(void) const;
bool isShadowing(void) const;
bool isDebugging(void) const;
CSharedShader getShader(void) const;
CSharedTexture getTexture(E_SHADER_SAMPLER sampler) const;
E_SHADER_SAMPLER getSamplerIndex(CSharedTextureRef texture) const;
void setCulling(bool value);
void setCullingMode(GLenum value);
void setBlending(bool value);
void setBlendingFunctionSource(GLenum value);
void setBlendingFunctionDestination(GLenum value);
void setDepthTest(bool value);
void setDepthMask(bool value);
void setClipping(bool value);
void setClippingPlane(const glm::vec4& value);
void setReflecting(bool value);
void setShadowing(bool value);
void setDebugging(bool value);
void setShader(CSharedShaderRef shader);
void setTexture(CSharedTextureRef texture,
E_SHADER_SAMPLER _sampler);
bool isLoaded(void) const;
bool isCommited(void) const;
void bind(void);
void unbind(void);
};
#endif
|
a49d5a2f1d0f34984f4b5bbbd6c938813d662dfb
|
70668b85b4946bb23e918db1b4a68a54910d9b36
|
/geeks/IES/valid_address.cpp
|
ab7d92a174fd8250d98cf824033e5b78dd76b691
|
[] |
no_license
|
Ishaan29/fuzzy-chainsaw-algo
|
397e9feddca2a25902081a9d9316923c151779f1
|
b4fa1f69721f5fe53745303879f9c8ff2c1a8e79
|
refs/heads/master
| 1,624,580,794,720,087,000
| 1,614,500,692,000,000,000
| 1,614,500,692,000,000,000
| 201,107,127
| 3
| 0
| null | 1,614,500,692,000,000,000
| 1,565,202,865,000,000,000
|
C++
|
UTF-8
|
C++
| false
| false
| 1,099
|
cpp
|
valid_address.cpp
|
#include <bits/stdc++.h>
using namespace std;
void c_p_c()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("/Users/ishan/Desktop/fuzzy-chainsaw-algo/input.txt", "r", stdin);
freopen("/Users/ishan/Desktop/fuzzy-chainsaw-algo/output.txt", "w", stdout);
#endif
}
void solve(){
string s; cin>>s;
bool w = false;
bool com = false;
bool fwd = false;
int w_cnt = 0;
int fw_cnt = 0;
for(int i = 0; i < s.length(); i++){
if(w_cnt == 3 && !w){
cout<<".";
w = true;
}
if(s[i] == 'w'){
w_cnt++;
}else{
w_cnt = 0;
}
if(i+3 <= s.length()){
if(s[i] == 'c' && s[i+1] == 'o' && s[i+2] == 'm' && !com){
cout<<".";
com = true;
fw_cnt = i+3;
}
}
if(i == fw_cnt && !fwd && i != 0){
cout<<"/";
fwd = true;
}
cout<<s[i];
}
}
int main(){
c_p_c();
int t; t = 1;
while(t--){
solve();
}
}
|
ed30dc26cb578e6b3d1e4d90434cc7b81e48f3a0
|
877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a
|
/app/src/main/cpp/dir40735/file41063.cpp
|
6a9decf72ebcc60f955eba8c0ef0bfcd3968687e
|
[] |
no_license
|
tgeng/HugeProject
|
829c3bdfb7cbaf57727c41263212d4a67e3eb93d
|
4488d3b765e8827636ce5e878baacdf388710ef2
|
refs/heads/master
| 1,661,101,134,161,627,000
| 1,590,630,843,000,000,000
| 1,590,630,843,000,000,000
| 267,468,475
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 115
|
cpp
|
file41063.cpp
|
#ifndef file41063
#error "macro file41063 must be defined"
#endif
static const char* file41063String = "file41063";
|
ffeaf24dcf6b08b0bf5bd1ef6973a78fa782b450
|
1766861304a430e4fc23bf442ffa70105ed0ca0d
|
/Series.h
|
fb14952a19831d074c11cef703d896f83e4c35ab
|
[] |
no_license
|
davidn3457/Situacionproblematc1033
|
2d7a301112d4ad33e0bf00c941b238c83a74519d
|
d3c19a8607a53a00fc70751a724e2772a1f09a83
|
refs/heads/master
| 1,681,167,396,570,048,000
| 1,619,585,296,000,000,000
| 1,619,585,296,000,000,000
| 362,203,686
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,227
|
h
|
Series.h
|
#ifndef Series_h
#define Series_h
#include <stdio.h>
#include "Serie.h"
class Series{
private:
Serie arrSeries[100];
int iCant;
public:
Series();
//Leer todas series y episodios desde un archivo
void leerArchivo();
//Reporta todas las series y al final se muestra la calificacion promedio de todas las series
void reporteTodasSeries();
//Reporte de series que tienen calificacion especifica
void reporteConCalificacion(double _calificacion);
//Reporte de series que tienen cierto genero
void reporteGenero(std::string _genero);
//Calcula la calificacion promedio de las series y despliega su titulo y calificacion promedio
void calculaCalPromedioSerie();
//Retorna el objeto serie que esta en posicion iS y recibe como parametros de entrada, no existe retorno una serie default y despliega un mensaje indicando que esa serie no existe
Serie getSerie(int iS);
//Cambia el contenido dentro de una serie del arreglo, recibiendo el nuevo valor de la serie y el numero de la serie que se quiere cambiar
void setSerie(int iS, Serie s);
//retorna la cantidad de series que hay hasta el momento
int getCantidadSeries();
};
#endif /* Series_h */
|
51538303c4b11483e59915653f27ab80d757d84f
|
1cb93ce35651d1352587b50f9f3be94d6053d94a
|
/drm/mediacas/plugins/clearkey/JsonAssetLoader.cpp
|
ee8dba3194684d2b57780398804288d46eedae2d
|
[
"LicenseRef-scancode-unicode",
"Apache-2.0"
] |
permissive
|
LineageOS/android_frameworks_av
|
7a685135784cd7dfad88c524acb7044cab188db5
|
be311717b151597a000cf3435812c56f915f2f4c
|
refs/heads/lineage-19.1
| 1,690,267,044,324,351,000
| 1,683,764,790,000,000,000
| 1,688,734,702,000,000,000
| 75,639,894
| 26
| 628
|
NOASSERTION
| 1,664,741,637,000,000,000
| 1,480,952,487,000,000,000
|
C++
|
UTF-8
|
C++
| false
| false
| 7,019
|
cpp
|
JsonAssetLoader.cpp
|
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//#define LOG_NDEBUG 0
#define LOG_TAG "JsonAssetLoader"
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/AString.h>
#include <media/stagefright/foundation/base64.h>
#include <media/stagefright/MediaErrors.h>
#include <utils/Log.h>
#include "JsonAssetLoader.h"
#include "protos/license_protos.pb.h"
namespace android {
namespace clearkeycas {
const String8 kIdTag("id");
const String8 kNameTag("name");
const String8 kLowerCaseOgranizationNameTag("lowercase_organization_name");
const String8 kEncryptionKeyTag("encryption_key");
const String8 kCasTypeTag("cas_type");
const String8 kBase64Padding("=");
JsonAssetLoader::JsonAssetLoader() {
}
JsonAssetLoader::~JsonAssetLoader() {
}
/*
* Extract a clear key asset from a JSON string.
*
* Returns OK if a clear key asset is extracted successfully,
* or ERROR_CAS_NO_LICENSE if the string doesn't contain a valid
* clear key asset.
*/
status_t JsonAssetLoader::extractAssetFromString(
const String8& jsonAssetString, Asset *asset) {
if (!parseJsonAssetString(jsonAssetString, &mJsonObjects)) {
return ERROR_CAS_NO_LICENSE;
}
if (mJsonObjects.size() < 1) {
return ERROR_CAS_NO_LICENSE;
}
if (!parseJsonObject(mJsonObjects[0], &mTokens))
return ERROR_CAS_NO_LICENSE;
if (!findKey(mJsonObjects[0], asset)) {
return ERROR_CAS_NO_LICENSE;
}
return OK;
}
//static
sp<ABuffer> JsonAssetLoader::decodeBase64String(const String8& encodedText) {
// Since android::decodeBase64() requires padding characters,
// add them so length of encodedText is exactly a multiple of 4.
int remainder = encodedText.length() % 4;
String8 paddedText(encodedText);
if (remainder > 0) {
for (int i = 0; i < 4 - remainder; ++i) {
paddedText.append(kBase64Padding);
}
}
return decodeBase64(AString(paddedText.string()));
}
bool JsonAssetLoader::findKey(const String8& jsonObject, Asset *asset) {
String8 value;
if (jsonObject.find(kIdTag) < 0) {
return false;
}
findValue(kIdTag, &value);
ALOGV("found %s=%s", kIdTag.string(), value.string());
asset->set_id(atoi(value.string()));
if (jsonObject.find(kNameTag) < 0) {
return false;
}
findValue(kNameTag, &value);
ALOGV("found %s=%s", kNameTag.string(), value.string());
asset->set_name(value.string());
if (jsonObject.find(kLowerCaseOgranizationNameTag) < 0) {
return false;
}
findValue(kLowerCaseOgranizationNameTag, &value);
ALOGV("found %s=%s", kLowerCaseOgranizationNameTag.string(), value.string());
asset->set_lowercase_organization_name(value.string());
if (jsonObject.find(kCasTypeTag) < 0) {
return false;
}
findValue(kCasTypeTag, &value);
ALOGV("found %s=%s", kCasTypeTag.string(), value.string());
// Asset_CasType_CLEARKEY_CAS = 1
asset->set_cas_type((Asset_CasType)atoi(value.string()));
return true;
}
void JsonAssetLoader::findValue(const String8 &key, String8* value) {
value->clear();
const char* valueToken;
for (Vector<String8>::const_iterator nextToken = mTokens.begin();
nextToken != mTokens.end(); ++nextToken) {
if (0 == (*nextToken).compare(key)) {
if (nextToken + 1 == mTokens.end())
break;
valueToken = (*(nextToken + 1)).string();
value->setTo(valueToken);
nextToken++;
break;
}
}
}
/*
* Parses a JSON objects string and initializes a vector of tokens.
*
* @return Returns false for errors, true for success.
*/
bool JsonAssetLoader::parseJsonObject(const String8& jsonObject,
Vector<String8>* tokens) {
jsmn_parser parser;
jsmn_init(&parser);
int numTokens = jsmn_parse(&parser,
jsonObject.string(), jsonObject.size(), NULL, 0);
if (numTokens < 0) {
ALOGE("Parser returns error code=%d", numTokens);
return false;
}
unsigned int jsmnTokensSize = numTokens * sizeof(jsmntok_t);
mJsmnTokens.clear();
mJsmnTokens.setCapacity(jsmnTokensSize);
jsmn_init(&parser);
int status = jsmn_parse(&parser, jsonObject.string(),
jsonObject.size(), mJsmnTokens.editArray(), numTokens);
if (status < 0) {
ALOGE("Parser returns error code=%d", status);
return false;
}
tokens->clear();
String8 token;
const char *pjs;
ALOGV("numTokens: %d", numTokens);
for (int j = 0; j < numTokens; ++j) {
pjs = jsonObject.string() + mJsmnTokens[j].start;
if (mJsmnTokens[j].type == JSMN_STRING ||
mJsmnTokens[j].type == JSMN_PRIMITIVE) {
token.setTo(pjs, mJsmnTokens[j].end - mJsmnTokens[j].start);
tokens->add(token);
ALOGV("add token: %s", token.string());
}
}
return true;
}
/*
* Parses JSON asset string and initializes a vector of JSON objects.
*
* @return Returns false for errors, true for success.
*/
bool JsonAssetLoader::parseJsonAssetString(const String8& jsonAsset,
Vector<String8>* jsonObjects) {
if (jsonAsset.isEmpty()) {
ALOGE("Empty JSON Web Key");
return false;
}
// The jsmn parser only supports unicode encoding.
jsmn_parser parser;
// Computes number of tokens. A token marks the type, offset in
// the original string.
jsmn_init(&parser);
int numTokens = jsmn_parse(&parser,
jsonAsset.string(), jsonAsset.size(), NULL, 0);
if (numTokens < 0) {
ALOGE("Parser returns error code=%d", numTokens);
return false;
}
unsigned int jsmnTokensSize = numTokens * sizeof(jsmntok_t);
mJsmnTokens.setCapacity(jsmnTokensSize);
jsmn_init(&parser);
int status = jsmn_parse(&parser, jsonAsset.string(),
jsonAsset.size(), mJsmnTokens.editArray(), numTokens);
if (status < 0) {
ALOGE("Parser returns error code=%d", status);
return false;
}
String8 token;
const char *pjs;
for (int i = 0; i < numTokens; ++i) {
pjs = jsonAsset.string() + mJsmnTokens[i].start;
if (mJsmnTokens[i].type == JSMN_OBJECT) {
token.setTo(pjs, mJsmnTokens[i].end - mJsmnTokens[i].start);
jsonObjects->add(token);
}
}
return true;
}
} // namespace clearkeycas
} // namespace android
|
a53ea340c5dfa96fc3411a0b43894caa7cfde6fc
|
4b5a008421fb71f83d948dc9f147e955ab4dc7b1
|
/uaMobi/dataproviders/ModesDescriptions.h
|
d867541c790f9afe266229736227982ebe1dab6b
|
[] |
no_license
|
ston1x/UNARetail
|
a205becbe3c69b3bd51127b6ec29c3e5abf340d0
|
491ced2068cb89ed24d7d5c23477fd80ca54b8dd
|
refs/heads/master
| 1,665,451,604,848,735,000
| 1,591,697,220,000,000,000
| 1,591,697,220,000,000,000
| 271,839,954
| 1
| 0
| null | 1,591,978,296,000,000,000
| 1,591,978,296,000,000,000
| null |
UTF-8
|
C++
| false
| false
| 2,473
|
h
|
ModesDescriptions.h
|
#pragma once
#include <QString>
#include <QList>
enum
#ifdef QT_VERSION5X
class
#endif
Modes
{
// This enum represents modes. Warning! All these values must be linked with entities and
// ready for QString convertation. Warning! Some settings arrays are hard linked to these numbers.
Search, Inventory, Supplies, Simple, Prices, Invoices
};
extern const int MODES_TOTAL;
typedef unsigned int uint;
inline uint qHash(Modes m)
// used in QHash container
{
return uint(m);
}
inline Modes modeFromInt(const int m)
{
if (m > 0 && m < MODES_TOTAL)
return static_cast<Modes>(m);
return Modes::Search;
}
bool hasModifiableSysfeed(Modes m);
extern const QString ModePrefixes[];
enum sendingMode { sendSent, sendUnsent, sendAll };
class ModeDescription
{
private:
Modes mode;
int sysfeed;
QList<int> serializationOrder;
bool floatControl;
long long int previousDocument;
bool attachNewDataToPrevious;
bool clearBeforeAttachingNewData;
bool allowInsertingTaxInvoiceNumber;
bool newBCMustHaveTaxInvoiceNumber;
protected:
virtual bool _deserialize(const QString&);
virtual QString _serialize() const;
public:
explicit ModeDescription();
explicit ModeDescription(Modes md);
explicit ModeDescription(QString& serialized);
ModeDescription(Modes m, int sf, QList<int>& sO, bool fc,long long int pvd, bool andtp, bool cband,
bool aITIN,
bool NBMHTIN
);
bool deserialize(const QString&);
QString serialize() const;
Modes getMode() const;
int getSysfeed() const;
const QList<int>& getSerializationOrder() const;
bool requiresFloatControl() const;
bool requiresAttachingToPreviousDoc() const;
bool mustClearBeforeAttaching() const;
long long int getPreviousDocNumber() const;
bool isInsertingTaxInvoiceNumAllowed() const;
bool isForbiddenInsertingWithoutTaxInvoice() const;
void setSysfeed(int);
void setSerializationOrder(QList<int>&);
void setFloatControl(bool);
void setAttachingToPrevDoc(bool);
void setCleanBeforeAttaching(bool);
void setPreviousDocument(long long int);
void setInsertingTaxNumber(bool);
void setForbiddingInsertingWithoutTaxInvoice(bool);
};
enum
#ifdef QT_VERSION5X
class
#endif
TableNames
{
Scanned, // Here are stored barcodes which was not uploaded
Uploaded, // Here are stored barcodes marked as sent
TempScan
};
inline uint qHash(TableNames t)
{
return uint(t);
}
extern const QString TableSuffixes[];
enum
#ifdef QT_VERSION5X
class
#endif
Destinations {
NetworkDestination, FileDestination
};
|
491e1101c18e4702a46cd041b6891689035e64b3
|
d24fa3d8dee5507a3b6b27bf788a0337530db538
|
/Gam200Engine/Scenes/HowtoPlay.hpp
|
48a2c91b71bd2278308f16a23c05c8ab5d26e4c6
|
[] |
no_license
|
wjm9932/GAM200Engine
|
5662ac1667aaa0e78f985425fcc9fb5f5b2f4e10
|
47ecd2862d3f9f380ecfea0660ebe477e9518f43
|
refs/heads/master
| 1,668,954,232,064,192,000
| 1,594,887,646,000,000,000
| 1,594,887,646,000,000,000
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,430
|
hpp
|
HowtoPlay.hpp
|
/******************************************************************************
Copyright (C) 2020 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior
written consent of DigiPen Institute of Technology is prohibited.
File Name: HowtoPlay.hpp
Author
- jjwon6218@gmail.com
Creation Date: 05.29.2020
Header file for how to play level
******************************************************************************/
#pragma once
#include <Scenes/Scene.hpp>
#include <Object/Players/Player.h>
#include <Object/Strings/String.hpp>
class Object;
class Player;
class String;
class HowToPlay : public Scene
{
public:
HowToPlay();
virtual ~HowToPlay();
void Update(float dt) override;
protected:
void GameRestart() override;
void Load() override;
void Unload() override;
void Input();
void Collision();
void InitObject();
private:
Object* movementIndicator1{};
Object* movementIndicator2{};
Object* movementExplanation{};
Object* rightArrow{};
Object* sizeIndicator{};
Object* sizeExplanation{};
Object* arrows1{};
Object* movableBox{};
Object* movableBox1{};
Object* movableBoxExplanation{};
Object* arrows2{};
Object* checkpoint{};
Object* checkpoint1{};
Object* checkpointExplanation{};
Object* leftArrow{};
Object* press;
Object* press1;
Object* press2;
Object* press3;
};
|
89d4f418e020ef3587b8daee1652560ae630304f
|
cef45cda6cd9e210eab6094313ec6d11c9b96cf4
|
/ex4/ex4.cpp
|
4059e7aa0e225eaceba25ea07e3ba2df9d468098
|
[
"MIT"
] |
permissive
|
nanaHa1003/NLA_SCML_2018
|
abf783d7d23145374e627a92e171f7c6612ba84b
|
b44d026fd7e5bc26b296f0961899a7bc7a4cecaf
|
refs/heads/master
| 1,620,743,905,878,185,000
| 1,517,587,944,000,000,000
| 1,517,587,944,000,000,000
| 117,707,258
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,081
|
cpp
|
ex4.cpp
|
#include <cassert>
#include <iostream>
#include <vector>
#include <algorithm>
#include <chrono>
#include <cuda_runtime.h>
#include "ex4.h"
void full_to_csr_ref(
int m, int n,
double *A, int lda,
int **rowptr, int **colidx, double **values) {
*rowptr = new int[m + 1];
int zero = 0;
std::fill(*rowptr, *rowptr + m + 1, zero);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
rowptr[0][j + 1] += (A[i * lda + j]) ?1 :0;
}
}
for (int i = 0; i < m; ++i) {
rowptr[0][i + 1] += rowptr[0][i];
}
*colidx = new int[rowptr[0][m]];
*values = new double[rowptr[0][m]];
int pos = 0;
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
if (A[i * lda + j]) {
colidx[0][pos] = j;
values[0][pos] = A[i * lda + j];
++pos;
}
}
}
}
int test(int size) {
if (size <= 0) return 0;
double *A = new double[size * size];
std::fill(A, A + size * size, 0.0);
if (size > 1) {
A[0] = 2.0;
A[1] = -1.0;
for (int i = 1; i < size - 1; ++i) {
A[i * size + i - 1] = -1.0;
A[i * size + i ] = 2.0;
A[i * size + i + 1] = -1.0;
}
A[size * size - 2] = -1.0;
A[size * size - 1] = 2.0;
} else if (size == 1) {
A[0] = 2.0;
}
int *rowptr, *colidx;
double *values;
full_to_csr_ref(size, size, A, size, &rowptr, &colidx, &values);
double *d_A;
cudaError_t cudaErr = cudaMalloc(reinterpret_cast<void **>(&d_A), size * size * sizeof(double));
assert(cudaErr == cudaSuccess);
cudaErr = cudaMemcpy(d_A, A, size * size * sizeof(double), cudaMemcpyHostToDevice);
assert(cudaErr == cudaSuccess);
int *d_rowptr, *d_colidx;
double *d_values;
full_to_csr(size, size, d_A, size, &d_rowptr, &d_colidx, &d_values);
// Verify results
int *h_rowptr = new int[size + 1];
int *h_colidx = new int[rowptr[size]];
double *h_values = new double[rowptr[size]];
cudaErr = cudaMemcpy(h_rowptr, d_rowptr, (size + 1) * sizeof(int), cudaMemcpyDeviceToHost);
assert(cudaErr == cudaSuccess);
cudaErr = cudaMemcpy(h_colidx, d_colidx, h_rowptr[size] * sizeof(int), cudaMemcpyDeviceToHost);
assert(cudaErr == cudaSuccess);
cudaErr = cudaMemcpy(h_values, d_values, h_rowptr[size] * sizeof(double), cudaMemcpyDeviceToHost);
assert(cudaErr == cudaSuccess);
int errcnt = 0;
for (int i = 0; i < size + 1; ++i) {
if (rowptr[i] != h_rowptr[i]) errcnt += 1;
}
for (int i = 0; i < rowptr[size]; ++i) {
if (colidx[i] != h_colidx[i]) errcnt += 1;
}
for (int i = 0; i < rowptr[size]; ++i) {
if (values[i] != h_values[i]) errcnt += 1;
}
cudaFree(d_A);
cudaFree(d_rowptr);
cudaFree(d_colidx);
cudaFree(d_values);
delete[] rowptr;
delete[] colidx;
delete[] values;
delete[] h_rowptr;
delete[] h_colidx;
delete[] h_values;
return errcnt;
}
int main() {
assert(test(1024) == 0);
std::vector<int> test_sizes = {{ 64, 128, 256, 512, 1024, 2048, 4096 }};
for (auto size: test_sizes) {
std::vector<double> A(size * size, 0.0);
A[0] = 2.0;
A[1] = -1.0;
for (size_t i = 1; i < size - 1; ++i) {
A[i * size + i - 1] = -1.0;
A[i * size + i ] = 2.0;
A[i * size + i + 1] = -1.0;
}
A[size * size - 2] = -1.0;
A[size * size - 1] = 2.0;
double *d_A;
cudaError_t cudaErr;
cudaErr = cudaMalloc(&d_A, A.size() * sizeof(double));
assert(cudaErr == cudaSuccess);
cudaErr = cudaMemcpy(d_A, A.data(), A.size() * sizeof(double), cudaMemcpyHostToDevice);
assert(cudaErr == cudaSuccess);
int *d_row, *d_col;
double *d_val;
full_to_csr(size, size, d_A, size, &d_row, &d_col, &d_val);
cudaFree(d_A);
cudaFree(d_row);
cudaFree(d_col);
cudaFree(d_val);
}
return 0;
}
|
f7b8775be769ffa9c9a0e2308a977d6455cc7090
|
de349aa71b8df2a39f0a7fccfef99795221f0135
|
/home_control_lib/include/repeat_invoker.h
|
182f11fe4bfc0db755c329b3bba5c5b02fabda31
|
[] |
no_license
|
odiubankov/home_control
|
aecf9848534250f83f7f959ee36c84d3ce24c641
|
d61d3870cc7bd994e2eefa8a241c34a04bcfe778
|
refs/heads/master
| 1,584,501,849,846,018,000
| 1,534,584,827,000,000,000
| 1,534,584,827,000,000,000
| 134,238,677
| 0
| 0
| null | 1,534,584,828,000,000,000
| 1,526,890,231,000,000,000
|
C++
|
UTF-8
|
C++
| false
| false
| 732
|
h
|
repeat_invoker.h
|
//
// Copyright(c) 2018 Oleksii Diubankov
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include <atomic>
#include <chrono>
#include <functional>
#include <thread>
namespace hctrl {
class RepeatInvoker
{
public:
RepeatInvoker(std::function<void()> handler, std::chrono::milliseconds timeout);
~RepeatInvoker();
RepeatInvoker(const RepeatInvoker&) = delete;
RepeatInvoker& operator=(const RepeatInvoker&) = delete;
RepeatInvoker(RepeatInvoker&&) = delete;
RepeatInvoker& operator=(RepeatInvoker&&) = delete;
private:
std::function<void()> handler_;
std::chrono::milliseconds timeout_;
std::atomic<bool> stop_;
std::thread invokeThread_;
};
}
|
0b007210350d0d3217fb156a3250cb155732fd89
|
097f47c14f8ce0152db2df8915bf4c82b5633976
|
/FYP_matrix/google-api/google/cloud/texttospeech/v1/cloud_tts.grpc.pb.cc
|
d004d068743068d8c4d8783c2233395165ebe02b
|
[] |
no_license
|
BenjaminChia/Ben_FYP_RPi_Matrix
|
a1bbffa854be723e59f60358a1dbe7a44e0a1898
|
5a7952774e3f10ddc5ca56dccba82dba25471fd7
|
refs/heads/master
| 1,585,465,853,329,139,000
| 1,537,491,248,000,000,000
| 1,537,491,248,000,000,000
| 149,655,972
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| true
| 5,747
|
cc
|
cloud_tts.grpc.pb.cc
|
// Generated by the gRPC C++ plugin.
// If you make any local change, they will be lost.
// source: google/cloud/texttospeech/v1/cloud_tts.proto
#include "google/cloud/texttospeech/v1/cloud_tts.pb.h"
#include "google/cloud/texttospeech/v1/cloud_tts.grpc.pb.h"
#include <grpcpp/impl/codegen/async_stream.h>
#include <grpcpp/impl/codegen/async_unary_call.h>
#include <grpcpp/impl/codegen/channel_interface.h>
#include <grpcpp/impl/codegen/client_unary_call.h>
#include <grpcpp/impl/codegen/method_handler_impl.h>
#include <grpcpp/impl/codegen/rpc_service_method.h>
#include <grpcpp/impl/codegen/service_type.h>
#include <grpcpp/impl/codegen/sync_stream.h>
namespace google {
namespace cloud {
namespace texttospeech {
namespace v1 {
static const char* TextToSpeech_method_names[] = {
"/google.cloud.texttospeech.v1.TextToSpeech/ListVoices",
"/google.cloud.texttospeech.v1.TextToSpeech/SynthesizeSpeech",
};
std::unique_ptr< TextToSpeech::Stub> TextToSpeech::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) {
(void)options;
std::unique_ptr< TextToSpeech::Stub> stub(new TextToSpeech::Stub(channel));
return stub;
}
TextToSpeech::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel)
: channel_(channel), rpcmethod_ListVoices_(TextToSpeech_method_names[0], ::grpc::internal::RpcMethod::NORMAL_RPC, channel)
, rpcmethod_SynthesizeSpeech_(TextToSpeech_method_names[1], ::grpc::internal::RpcMethod::NORMAL_RPC, channel)
{}
::grpc::Status TextToSpeech::Stub::ListVoices(::grpc::ClientContext* context, const ::google::cloud::texttospeech::v1::ListVoicesRequest& request, ::google::cloud::texttospeech::v1::ListVoicesResponse* response) {
return ::grpc::internal::BlockingUnaryCall(channel_.get(), rpcmethod_ListVoices_, context, request, response);
}
::grpc::ClientAsyncResponseReader< ::google::cloud::texttospeech::v1::ListVoicesResponse>* TextToSpeech::Stub::AsyncListVoicesRaw(::grpc::ClientContext* context, const ::google::cloud::texttospeech::v1::ListVoicesRequest& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderFactory< ::google::cloud::texttospeech::v1::ListVoicesResponse>::Create(channel_.get(), cq, rpcmethod_ListVoices_, context, request, true);
}
::grpc::ClientAsyncResponseReader< ::google::cloud::texttospeech::v1::ListVoicesResponse>* TextToSpeech::Stub::PrepareAsyncListVoicesRaw(::grpc::ClientContext* context, const ::google::cloud::texttospeech::v1::ListVoicesRequest& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderFactory< ::google::cloud::texttospeech::v1::ListVoicesResponse>::Create(channel_.get(), cq, rpcmethod_ListVoices_, context, request, false);
}
::grpc::Status TextToSpeech::Stub::SynthesizeSpeech(::grpc::ClientContext* context, const ::google::cloud::texttospeech::v1::SynthesizeSpeechRequest& request, ::google::cloud::texttospeech::v1::SynthesizeSpeechResponse* response) {
return ::grpc::internal::BlockingUnaryCall(channel_.get(), rpcmethod_SynthesizeSpeech_, context, request, response);
}
::grpc::ClientAsyncResponseReader< ::google::cloud::texttospeech::v1::SynthesizeSpeechResponse>* TextToSpeech::Stub::AsyncSynthesizeSpeechRaw(::grpc::ClientContext* context, const ::google::cloud::texttospeech::v1::SynthesizeSpeechRequest& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderFactory< ::google::cloud::texttospeech::v1::SynthesizeSpeechResponse>::Create(channel_.get(), cq, rpcmethod_SynthesizeSpeech_, context, request, true);
}
::grpc::ClientAsyncResponseReader< ::google::cloud::texttospeech::v1::SynthesizeSpeechResponse>* TextToSpeech::Stub::PrepareAsyncSynthesizeSpeechRaw(::grpc::ClientContext* context, const ::google::cloud::texttospeech::v1::SynthesizeSpeechRequest& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderFactory< ::google::cloud::texttospeech::v1::SynthesizeSpeechResponse>::Create(channel_.get(), cq, rpcmethod_SynthesizeSpeech_, context, request, false);
}
TextToSpeech::Service::Service() {
AddMethod(new ::grpc::internal::RpcServiceMethod(
TextToSpeech_method_names[0],
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler< TextToSpeech::Service, ::google::cloud::texttospeech::v1::ListVoicesRequest, ::google::cloud::texttospeech::v1::ListVoicesResponse>(
std::mem_fn(&TextToSpeech::Service::ListVoices), this)));
AddMethod(new ::grpc::internal::RpcServiceMethod(
TextToSpeech_method_names[1],
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler< TextToSpeech::Service, ::google::cloud::texttospeech::v1::SynthesizeSpeechRequest, ::google::cloud::texttospeech::v1::SynthesizeSpeechResponse>(
std::mem_fn(&TextToSpeech::Service::SynthesizeSpeech), this)));
}
TextToSpeech::Service::~Service() {
}
::grpc::Status TextToSpeech::Service::ListVoices(::grpc::ServerContext* context, const ::google::cloud::texttospeech::v1::ListVoicesRequest* request, ::google::cloud::texttospeech::v1::ListVoicesResponse* response) {
(void) context;
(void) request;
(void) response;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
::grpc::Status TextToSpeech::Service::SynthesizeSpeech(::grpc::ServerContext* context, const ::google::cloud::texttospeech::v1::SynthesizeSpeechRequest* request, ::google::cloud::texttospeech::v1::SynthesizeSpeechResponse* response) {
(void) context;
(void) request;
(void) response;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
} // namespace google
} // namespace cloud
} // namespace texttospeech
} // namespace v1
|
End of preview.
No dataset card yet
- Downloads last month
- 929