本文整理汇总了C++中sa函数的典型用法代码示例。如果您正苦于以下问题:C++ sa函数的具体用法?C++ sa怎么用?C++ sa使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sa函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sa
bool
Lorica::Proxy::setup_shutdown_handler(void)
{
ACE_Sig_Set sigset;
// Register signal handlers.
sigset.sig_add(SIGINT);
sigset.sig_add(SIGUSR1);
sigset.sig_add(SIGUSR2);
sigset.sig_add(SIGTERM);
// Register the <handle_signal> method to process all the signals in
// <sigset>.
ACE_Sig_Action sa(sigset,
(ACE_SignalHandler)Lorica::signal_handler);
ACE_UNUSED_ARG(sa);
return true;
}
开发者ID:colding,项目名称:lorica,代码行数:19,代码来源:proxy.cpp
示例2: ft_dirread
int ft_dirread(s_dir *d, s_arg *a, char **argv)
{
int cd;
d->open = opendir(argv[a->arc]);
if (d->open == NULL)
return (1);
if(a->rm == 1)
srm(d,a, argv);
else
sa(d,a);
//cd = closedir(d->open);
return (0);
// ft_putnbr(d->rd->d_type);// permet de connaitre le type de fichir, un fichier standard = 8 et un dossier = 4
// ft_putnbr(d->info->st_mode);
// ft_putnbr(d->info->st_mode);
// ft_putchar('\n');
}
开发者ID:hikkary,项目名称:ft_ls,代码行数:19,代码来源:main.c
示例3: expandInterfaces
uint16_t SocketAcceptor::listen(const std::vector<std::string>& interfaces, uint16_t port, int backlog, const SocketFactory& factory)
{
std::vector<std::string> addresses = expandInterfaces(interfaces);
std::string sport(boost::lexical_cast<std::string>(port));
if (addresses.empty()) {
// We specified some interfaces, but couldn't find addresses for them
QPID_LOG(warning, "TCP/TCP6: No specified network interfaces found: Not Listening");
return 0;
}
int listeningPort = 0;
for (unsigned i = 0; i<addresses.size(); ++i) {
QPID_LOG(debug, "Using interface: " << addresses[i]);
SocketAddress sa(addresses[i], sport);
do {
try {
// If we were told to figure out the port then only allow listening to one address
if (port==0 && listeningPort!=0) {
// Print warning if the user specified more than one interface
QPID_LOG(warning, "Specified port=0: Only listened to: " << sa.asString());
return listeningPort;
}
QPID_LOG(info, "Listening to: " << sa.asString());
std::auto_ptr<Socket> s(factory());
uint16_t lport = s->listen(sa, backlog);
QPID_LOG(debug, "Listened to: " << lport);
addListener(s.release());
if (listeningPort==0) listeningPort = lport;
} catch (std::exception& e) {
QPID_LOG(warning, "Couldn't listen to: " << sa.asString() << ": " << e.what());
}
} while (sa.nextAddress());
}
if (listeningPort==0) {
throw Exception("Couldn't find any network address to listen to");
}
return listeningPort;
}
开发者ID:MorganLindqvist,项目名称:debian-qpid-cpp,代码行数:42,代码来源:SocketTransport.cpp
示例4: resolve
void resolve(t_stack *stack, char **argv)
{
get_list(stack, argv);
if (stack->number_in_a == 2)
sa(stack, 1);
while (stack->number_in_b || !is_sort(stack))
{
if (stack->number_in_a < 4)
quicky_sort(stack);
else
naive_algo(stack);
}
if (stack->number_of_moves)
ft_printf("Moves required : [%[[FG_GRE,SP_RST]d]\n", stack->n_moves);
if (stack->end_status)
print_stack(&stack->a_begin, stack->number_in_a, 'a', stack->color);
if (!stack->no_command)
print_command(stack);
free_stack(stack);
}
开发者ID:Lexouu77,项目名称:42Projects,代码行数:20,代码来源:resolve.c
示例5: ArrayTest8
void ArrayTest8(ostream & buffer)
{
buffer << "\r\nArrays: String Object Example"
"\r\n-----------------------------\r\n";
SimpleArray<SimpleStr> sa(10);
sa[0] = SimpleStr("Zero");
sa[1] = "One";
sa[2] = "Two";
sa[3] = "Three";
sa[4] = "Four";
sa[5] = "Five";
sa[6] = "Six";
sa[7] = "Seven";
sa[8] = "Eight";
sa[9] = "Nine";
buffer << "String array test = " << sa << "\r\n";
}
开发者ID:heavilessrose,项目名称:my-sync,代码行数:20,代码来源:simplearray.cpp
示例6: main
void main()
{
int a[20], i, e;
printf("enter size of array\t");
scanf("%d", &n);
if (n >0)
{
printf("enter array elements:");
for (i = 0; i < n; i++)
scanf("%d", &a[i]);
printf("enter the element\t");
scanf("%d", &e);
sa(a, e);
printf("modified array\n");
for (i = 0; i < n; i++)
printf("%d\t", a[i]);
}
else
printf("invalid size");
}
开发者ID:Saitejaparsi,项目名称:mrnd2016,代码行数:20,代码来源:Sorted_array_insertion.c
示例7: construct_sa
void construct_sa(cache_config& config)
{
static_assert(t_width == 0 or t_width == 8 , "construct_sa: width must be `0` for integer alphabet and `8` for byte alphabet");
const char* KEY_TEXT = key_text_trait<t_width>::KEY_TEXT;
if (t_width == 8) {
typedef int_vector<t_width> text_type;
text_type text;
load_from_cache(text, KEY_TEXT, config);
// call divsufsort
int_vector<> sa(text.size(), 0, bits::hi(text.size())+1);
algorithm::calculate_sa((const unsigned char*)text.data(), text.size(), sa);
store_to_cache(sa, conf::KEY_SA, config);
} else if (t_width == 0) {
// call qsufsort
int_vector<> sa;
sdsl::qsufsort::construct_sa(sa, config.file_map[KEY_TEXT].c_str(), 0);
store_to_cache(sa, conf::KEY_SA, config);
} else {
std::cerr << "Unknown alphabet type" << std::endl;
}
}
开发者ID:chenlonggang,项目名称:sdsl-lite,代码行数:21,代码来源:construct_sa.hpp
示例8: index_csa_psi_text
/*!
* Constructor for building the Index
* \param[in] str C-string of the text
*/
index_csa_psi_text(const unsigned char *str) : index() {
size_t n = strlen((const char*)str);
int_vector<> sa(n+1, 0, bit_magic::l1BP(n+1)+1);
algorithm::calculate_sa(str, n+1, sa); // calculate the suffix array sa of str
int_vector<> m_psi;
sdsl::algorithm::sa2psi(sa, m_psi);
psi = EncVector(m_psi);
setText(str, n+1);
text = int_vector<>(sa.size(), 0, bit_magic::l1BP(sigma)+1);
for (size_t i=0; i<sa.size(); i++) text[i] = char2comp[str[i]];
/* Construct the SA-Samples */
m_sa_sample.setIntWidth( bit_magic::l1BP(sa.size())+1 );
m_sa_sample.resize( (sa.size()+SampleDens-1)/SampleDens );
size_t i=0, idx=0;
for(int_vector<>::const_iterator it = sa.begin(); i < sa.size(); it += (ptrdiff_t)SampleDens, i += SampleDens, ++idx) {
m_sa_sample[idx] = *it;
}
}
开发者ID:cpockrandt,项目名称:pr_dict_cmp,代码行数:25,代码来源:index_csa_psi_text.hpp
示例9: btwEncode
vector<int> btwEncode(const vector<int> &src) {
// O(n*lgn*lgn). probably faster than O(n*lgn) version
int len = src.size();
vector<int> sa(len), rank(len);
for(int i=0; i<len; ++i) rank[sa[i] = i] = src[i];
for(int ll=1, cnt=0; cnt!=len; ll<<=1, cnt=rank[sa.back()]+1) {
auto cmp = [&](const int l, const int r) {
if( rank[l]!=rank[r] ) return rank[l] < rank[r];
return rank[(l+ll)%len] < rank[(r+ll)%len];
};
sort(sa.begin(), sa.end(), cmp);
vector<int> tmp = rank;
tmp[sa[0]] = 0;
for(int i=1; i<sa.size(); ++i)
tmp[sa[i]] = tmp[sa[i-1]] + cmp(sa[i-1], sa[i]);
rank = tmp;
}
vector<int> rst(len);
for(int i=0; i<len; ++i) rst[i] = src[(sa[i]+len-1)%len];
return rst;
}
开发者ID:sunset1995,项目名称:ACM_ICPC_codebook,代码行数:21,代码来源:String_BWT.cpp
示例10: GetSuffixArray
// O(N(lgN)^2)
std::vector<int> GetSuffixArray(const std::string& s) {
// sa, group, t
std::vector<int> sa(s.size());
for (int i = 0; i < s.size(); ++i)
sa[i] = i;
std::vector<int> group(s.size()+1, -1);
for (int i = 0; i < s.size(); ++i)
group[i] = s[i];
int t = 1;
while (true) {
printf("[%d] ---------------------------------------\n", t);
// sort suffix array
Comp c(s, group, t);
std::sort(sa.begin(), sa.end(), c);
printf("[%d] =======================================\n", t);
// PrintSuffixArray(s, sa);
// make new t
t *= 2;
// base condition
if (t >= s.size())
break;
// make new group for 2t
std::vector<int> group2(s.size() + 1, -1);
group2[sa[0]] = 0;
for (int i = 1; i < s.size(); ++i) {
if (c(sa[i-1], sa[i]))
group2[sa[i]] = group2[sa[i-1]] + 1;
else
group2[sa[i]] = group2[sa[i-1]];
}
group = group2;
}
return sa;
}
开发者ID:iamslash,项目名称:dsalgorithm,代码行数:40,代码来源:a.cpp
示例11: fill_a
void fill_a(t_algo *algo, t_info *info)
{
t_list *last_a;
last_a = get_last(algo->stack_a);
while (algo->stack_b && (algo->op_count < info->in_count))
{
if ((algo->stack_b->next
&& *(int*)algo->stack_b->data < *(int*)algo->stack_b->next->data)
&& (algo->stack_a->next
&& *(int*)algo->stack_a->data > *(int*)algo->stack_a->next->data))
ss(algo);
if (algo->stack_b->next
&& *(int*)algo->stack_b->data < *(int*)algo->stack_b->next->data)
sb(algo);
if (algo->stack_a->next
&& *(int*)algo->stack_a->data > *(int*)algo->stack_a->next->data)
sa(algo);
pa(algo);
last_a = get_last(algo->stack_a);
}
}
开发者ID:deandt100,项目名称:push_swap,代码行数:22,代码来源:split_sort.c
示例12: _MEMBER_FUNCTION_IMPL
_MEMBER_FUNCTION_IMPL( XmlNode, SetAttribute )
{
StackHandler sa(v);
_CHECK_SELF( TiXmlNode, XmlNode );
const char* szAttribute = (const char*)sa.GetString( 2 );
const char* szValue = (const char*)sa.GetString( 3 );
TiXmlElement* pNode = (TiXmlElement*)self;
if ( pNode )
{
pNode->SetAttribute( szAttribute, szValue );
sa.Return( true );
return 1;
}
sa.Return( false );
return 1;
}
开发者ID:jack9267,项目名称:vcmpserver,代码行数:22,代码来源:SQXmlFuncs.cpp
示例13: sa
//-----------------------------------------------------------------------------
// Name: SendVoiceMessage
// Desc: Sends a voice message over the network, to everyone (NULL) or a
// specific recipient.
//-----------------------------------------------------------------------------
int CVoiceManager::SendVoiceMessage( const VoiceMessage* pMsg, const CXBSockAddr* psaDest )
{
int nBytes = 0;
// Non-reliable message - these get sent directly via VDP in all cases
if( psaDest )
{
// If destined for a specific player, send straight to them
nBytes += m_DirectSock.SendTo( pMsg, pMsg->GetSize(), psaDest->GetPtr() );
}
else
{
// Send to our current list of voice targets:
for( int i = 0; i < numVoiceTargets; ++i )
{
CXBSockAddr sa( xbOnlineInfo.xbPlayerList[voiceTargets[i].index].inAddr, DIRECT_PORT );
nBytes += m_DirectSock.SendTo( pMsg, pMsg->GetSize(), sa.GetPtr() );
}
}
return nBytes;
}
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:27,代码来源:XBVoice.cpp
示例14: checker_calc
int checker_calc(t_e *e)
{
char *line;
while (get_next_line(0, &line) != 0)
{
if (ft_strcmp("sa", line) == 0)
sa(e->l_a);
else if (ft_strcmp("sb", line) == 0)
sb(e->l_b);
else if (ft_strcmp("ss", line) == 0)
ss(e->l_a, e->l_b);
else if (ft_strcmp("ra", line) == 0)
ra(e->l_a);
else if (ft_strcmp("rb", line) == 0)
rb(e->l_b);
else if (ft_strcmp("rr", line) == 0)
rr(e->l_a, e->l_b);
else if (ft_strcmp("rra", line) == 0)
rra(e->l_a);
else if (ft_strcmp("rrb", line) == 0)
rrb(e->l_b);
else if (ft_strcmp("rrr", line) == 0)
rrr(e->l_a, e->l_b);
else if (ft_strcmp("pa", line) == 0)
pa(e->l_a, e->l_b);
else if (ft_strcmp("pb", line) == 0)
pb(e->l_a, e->l_b);
else
{
ft_putendl_fd("Error", 2);
ft_memdel((void **)&line);
return (0);
}
ft_memdel((void **)&line);
}
return (1);
}
开发者ID:ajuber,项目名称:project-push_swap3,代码行数:38,代码来源:main_checker.c
示例15: lock
const HostEntry& DNS::hostByAddress(const IPAddress& address)
{
FastMutex::ScopedLock lock(_mutex);
#if defined(_WIN32) && defined(POCO_HAVE_IPv6)
SocketAddress sa(address, 0);
static char fqname[1024];
if (getnameinfo(sa.addr(), sa.length(), fqname, sizeof(fqname), NULL, 0, 0) == 0)
{
DNSCache::const_iterator it = _cache.find(std::string(fqname));
if (it != _cache.end())
{
return it->second;
}
else
{
struct addrinfo* pAI;
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
if (getaddrinfo(fqname, NULL, &hints, &pAI) == 0)
{
std::pair<DNSCache::iterator, bool> res = _cache.insert(std::pair<std::string, HostEntry>(std::string(fqname), HostEntry(pAI)));
freeaddrinfo(pAI);
return res.first->second;
}
}
}
#else
struct hostent* he = gethostbyaddr(reinterpret_cast<const char*>(address.addr()), address.length(), address.af());
if (he)
{
std::pair<DNSCache::iterator, bool> res = _cache.insert(std::pair<std::string, HostEntry>(std::string(he->h_name), HostEntry(he)));
return res.first->second;
}
#endif
error(lastError(), address.toString()); // will throw an appropriate exception
throw NetException(); // to silence compiler
}
开发者ID:carvalhomb,项目名称:tsmells,代码行数:38,代码来源:DNS.cpp
示例16: IndexError
template< class T > T Correlation< T >::operator () (const vector < T > & a, const vector < T > & b) const
{
static char F_Name[] = "template< class T > T Correlation< T >::operator () (const vector < T > & a, const vector < T > & b) const";
if(a.size() != b.size()) {
TKVPairList kvlist;
kvlist.push_back(TKVPair("Size", a.size()));
kvlist.push_back(TKVPair("Size", b.size()));
throw IndexError(F_Name, kvlist);
}
T av_a, av_b, d_a, d_b, sp(0), sa(0), sb(0);
av_a = average(a);
av_b = average(b);
for(unsigned i=0; i<a.size(); i++) {
d_a = a[i] - av_a;
d_b = b[i] - av_b;
sp += d_a * d_b;
sa += SQR(d_a);
sb += SQR(d_b);
}
return sp / sqrt(sa * sb);
}
开发者ID:proofy,项目名称:boss,代码行数:23,代码来源:dsp_distances.cpp
示例17: buildSuffixArray
vector<int> buildSuffixArray(const vector<int> &str, int endOfString=-1) {
// sa: i -> start position of str
// O(n*lgn*lgn). probably faster than O(n*lgn) version
int len = str.size();
vector<int> sa(len+1), rank(len+1);
for(int i=0; i<len; ++i) rank[sa[i] = i] = str[i];
rank[sa.back() = len] = endOfString;
for(int ll=1, cnt=0; cnt!=len; ll<<=1, cnt=rank[sa.back()]) {
auto cmp = [&](const int l, const int r) {
if( rank[l]!=rank[r] ) return rank[l] < rank[r];
int lv = (l+ll < len) ? rank[l+ll] : 0;
int rv = (r+ll < len) ? rank[r+ll] : 0;
return lv < rv;
};
sort(sa.begin(), sa.end(), cmp);
vector<int> tmp = rank;
tmp[sa[0]] = 0;
for(int i=1; i<sa.size(); ++i)
tmp[sa[i]] = tmp[sa[i-1]] + cmp(sa[i-1], sa[i]);
rank = tmp;
}
return sa;
}
开发者ID:sunset1995,项目名称:ACM_ICPC_codebook,代码行数:23,代码来源:String_Suffix_Array.cpp
示例18: checktwolast
void checktwolast(t_ps *ps)
{
t_dnode *current;
t_dnode *prev;
if (stacklen(ps->stacka) > 4)
{
current = ps->stacka->list;
while (current->next)
{
prev = current;
current = current->next;
}
if (prev->value > current->value)
{
rra(ps);
rra(ps);
sa(ps);
ra(ps);
ra(ps);
}
}
}
开发者ID:Denis2222,项目名称:push_swap,代码行数:23,代码来源:algobubble.c
示例19: ft_put_sol
void ft_put_sol(unsigned int i, char op, t_swap **ba, t_swap **bb)
{
if (i / 8)
ft_put_sol(i / 8, op, ba, bb);
if (i % 8 == 0)
{
ft_putstr("sa ");
op ? sa(ba) : 0;
}
else if (i % 8 == 1)
{
ft_putstr("ra ");
op ? ra(ba) : 0;
}
else if (i % 8 == 2)
{
ft_putstr("rra ");
op ? rra(ba) : 0;
}
ft_suite_de_merde(i, op, ba, bb);
op ? ft_print_list(*ba, 1) : 0;
op ? ft_print_list(*bb, 0) : 0;
}
开发者ID:anasse82,项目名称:push_swap,代码行数:23,代码来源:ft_algo_bf.c
示例20: ipToAddrs
vector<SockAddr> ipToAddrs(const char* ips, int port, bool useUnixSockets) {
vector<SockAddr> out;
if (*ips == '\0') {
out.push_back(SockAddr("0.0.0.0", port)); // IPv4 all
if (IPv6Enabled())
out.push_back(SockAddr("::", port)); // IPv6 all
#ifndef _WIN32
if (useUnixSockets)
out.push_back(SockAddr(makeUnixSockPath(port).c_str(), port)); // Unix socket
#endif
return out;
}
while(*ips) {
string ip;
const char * comma = strchr(ips, ',');
if (comma) {
ip = string(ips, comma - ips);
ips = comma + 1;
}
else {
ip = string(ips);
ips = "";
}
SockAddr sa(ip.c_str(), port);
out.push_back(sa);
#ifndef _WIN32
if (useUnixSockets && (sa.getAddr() == "127.0.0.1" || sa.getAddr() == "0.0.0.0")) // only IPv4
out.push_back(SockAddr(makeUnixSockPath(port).c_str(), port));
#endif
}
return out;
}
开发者ID:Desartstudio,项目名称:mongo-nonx86,代码行数:37,代码来源:listen.cpp
注:本文中的sa函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论