本文整理汇总了C++中prepend函数的典型用法代码示例。如果您正苦于以下问题:C++ prepend函数的具体用法?C++ prepend怎么用?C++ prepend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prepend函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepend
Node Node::prepend(const std::string& tag, const Attributes& attributes, const std::string& text) {
Node child = prepend(tag);
for(auto attribute : attributes){
child.pimpl_->append_attribute(attribute.first.c_str()) = attribute.second.c_str();
}
if(text.length()>0) child.pimpl_->append_child(pugi::node_pcdata).set_value(text.c_str());
return child;
}
示例2: getAxisRotation
void Matrix3D::prependRotation(const float degrees, const Vector3D &axis, Vector3D *pivot) {
if (pivot) {
getAxisRotation(axis.x, axis.y, axis.y, pivot->x, pivot->y, pivot->z, degrees, _mt);
} else {
getAxisRotation(axis.x, axis.y, axis.y, 0, 0, 0, degrees, _mt);
}
prepend(_mt);
}
示例3: assert
template <class elem_t, class holder_t> void
cdlist_tos_base<elem_t, holder_t>::insert(size_t elem_num,
elem_t the_elem)
{
assert(elem_num >= 0);
size_t total;
holder_t *follow;
if (elem_num == 0)
{
prepend(the_elem);
return;
}
if (elem_num >= _cached_size)
{
while (_cached_size < elem_num)
append(zero((elem_t *)0));
append(the_elem);
return;
}
else if (elem_num - 1 <= _cached_index / 2)
{
/* Start at front. */
total = 0;
follow = _head_e;
}
else if (elem_num - 1 <= (_cached_index + _cached_size) / 2)
{
/* Start at cache. */
total = _cached_index;
follow = _cached_e;
}
else
{
/* Start at end. */
total = _cached_size - 1;
follow = _tail_e;
}
while (total < elem_num - 1)
{
++total;
follow = follow->next;
}
while (total > elem_num - 1)
{
--total;
follow = follow->previous;
}
holder_t *new_e = new holder_t(the_elem, follow->next, follow);
follow->next = new_e;
if (_tail_e == follow)
_tail_e = new_e;
else
new_e->next->previous = new_e;
_cached_index = elem_num;
_cached_e = new_e;
++_cached_size;
}
示例4: source_vertices
/* Returns the list of source vertices in g */
static List source_vertices(Graph graph) {
List sources = NULL;
for (int i = 0; i < graph->order; i++) {
if (!graph->vertices[i].in)
prepend(&sources, graph->vertices + i);
}
return sources;
}
示例5: getPath
// Returns the path from the source to given vertex
// Pre: 1 <= u <= getOrder(G)
void getPath(List L, Graph G, int u) {
if(getSource(G) == NIL) {
printf("Graph Error: calling getPath() with NULL source\n");
}
if(u < 1 || u > getOrder(G)) {
printf("Graph Error: calling getPath() with vertex out of bounds\n");
exit(1);
}
int s = G->source;
if(u == s) {
prepend(L, s);
} else if(G->parent[u] == NIL) {
append(L, NIL);
} else {
prepend(L, u);
getPath(L, G, G->parent[u]);
}
}
示例6: domain
namespace boost { namespace hana {
struct Function {
struct hana {
struct operators
: boost::hana::operators::of<Comparable>
{ };
};
};
template <typename Domain, typename Codomain, typename F, typename = operators::adl>
struct function_type {
struct hana { using datatype = Function; };
Domain dom;
Codomain cod;
F def;
friend constexpr auto domain(function_type f)
{ return f.dom; }
friend constexpr auto codomain(function_type f)
{ return f.cod; }
template <typename X>
constexpr auto operator()(X x) const {
if (!elem(domain(*this), x))
throw std::domain_error{"use of a hana::function with an argument out of the domain"};
return def(x);
}
};
BOOST_HANA_CONSTEXPR_LAMBDA auto function = [](auto domain, auto codomain) {
return [=](auto definition) {
return function_type<decltype(domain), decltype(codomain), decltype(definition)>{
domain, codomain, definition
};
};
};
BOOST_HANA_CONSTEXPR_LAMBDA auto frange = [](auto f) {
// Note: that would be better handled by a set data structure, but
// whatever for now.
return foldl(transform(domain(f), f), make<Tuple>(), [](auto xs, auto x) {
return if_(elem(xs, x), xs, prepend(x, xs));
});
};
template <>
struct equal_impl<Function, Function> {
template <typename F, typename G>
static constexpr auto apply(F f, G g) {
return domain(f) == domain(g) && all_of(domain(f), demux(equal)(f, g));
}
};
}} // end namespace boost::hana
示例7: new_edge_node
Graph *add_edge(Graph *gr, uint32_t src, uint32_t dst, double prb) {
EdgeNode *dst_node = new_edge_node(dst);
dst_node->prob = prb;
Vertex *src_vertex = gr->vertices[src];
if (src_vertex != NULL) { /* Don't access NULL pointers */
src_vertex->edges= prepend(dst_node, src_vertex->edges);
src_vertex->num_edges = src_vertex->num_edges + 1;
}
return gr;
}
示例8: add_depth
/*
* If the previous process is your parent increase identation level.
*/
int add_depth(pid_t parent, pid_t pid, struct node **head)
{
int rlist;
if (parent == pid) {
rlist = prepend(head, (pid_t) parent);
return rlist;
}
return 2;
}
示例9: ins_after
Pix BaseDLList::ins_after(Pix p, const void *datum) {
if (p == 0) return prepend(datum);
BaseDLNode* u = (BaseDLNode*) p;
BaseDLNode* t = copy_node(datum);
t->bk = u;
t->fd = u->fd;
u->fd->bk = t;
u->fd = t;
return Pix(t);
}
示例10: map_add
/* Adds a key-value pair to a map. */
void map_add(Map *map, Hashable *key, Value *value)
{
int i; //holds
for (i = 0; i<map->n; i++) {
if (map->lists[i] == NULL){
map->lists[i] = prepend(key, value, NULL);
break;
}
}
}
示例11:
inline
Ptr
operator*(Ptr value)
{
auto m1 = Matrix4x4::create(shared_from_this());
m1->prepend(value);
return m1;
}
示例12: packRaw
// take binary data and pack it to a TCP pack
QByteArray PackParser::packRaw(const QByteArray &content)
{
auto result = content;
quint32 length = content.length();
uchar c1, c2, c3, c4;
c1 = length & 0xFF;
length >>= 8;
c2 = length & 0xFF;
length >>= 8;
c3 = length & 0xFF;
length >>= 8;
c4 = length & 0xFF;
result.prepend(c1);
result.prepend(c2);
result.prepend(c3);
result.prepend(c4);
return result;
}
示例13: reserve
Polygon::Polygon(const Circle& circle, int points) {
if(points <= 0) points = round(circle.radius() * 15);
if(points < 3) points = 3;
qreal max = 2 * M_PI;
qreal inc = max / points;
reserve(points);
for(qreal d = 0; d < max; d += inc) {
prepend(Point(cos(d) * circle.radius() + circle.center().x(),
sin(d) * circle.radius() + circle.center().y()));
}
}
示例14: build_n_nodes
struct node* build_n_nodes(int num)
{
struct node **ref_plast;
struct node *phead = NULL;
int i;
ref_plast = &phead;
for(i = 0; i < num; i++) {
prepend(ref_plast, i);
ref_plast = &((*ref_plast)->next);
}
return phead;
}
示例15: prepend
ByteArray& ByteArray::prepend(const ByteArray& other)
{
if (isEmpty())
{
d = other.d;
}
else
{
prepend(other.data(), other.size());
}
return *this;
}