本文整理汇总了C++中sa函数的典型用法代码示例。如果您正苦于以下问题:C++ sa函数的具体用法?C++ sa怎么用?C++ sa使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sa函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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');
}
示例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;
}
示例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);
}
示例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";
}
示例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");
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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
}