Example #1
0
File: test.c Project: nexa/se
void vector()
{
  vector_t vec, *v;
  v = &vec;

  vector_init(v, 10);
  vector_fit(v, (void*)1);
  vector_fit(v, (void*)2);
  vector_fit(v, (void*)3);
  vector_fit(v, (void*)4);

 

  pvi(v);
  pvii(v, 2);

  vector_enable(v, 2);

  pvi(v);
  pvii(v, 2);
  vector_fit(v, (void*)5);
  pvi(v);
  pvii(v, 2);

  vector_clear(v);
}
    intrusive_ptr<const Value> AccumulatorPush::evaluate(
        const intrusive_ptr<Document> &pDocument) const {
        verify(vpOperand.size() == 1);
        intrusive_ptr<const Value> prhs(vpOperand[0]->evaluate(pDocument));

        if (prhs->getType() == Undefined)
            ; /* nothing to add to the array */
        else if (!pCtx->getInRouter())
            vpValue.push_back(prhs);
        else {
            /*
              If we're in the router, we need to take apart the arrays we
              receive and put their elements into the array we are collecting.
              If we didn't, then we'd get an array of arrays, with one array
              from each shard that responds.
             */
            verify(prhs->getType() == Array);
            
            intrusive_ptr<ValueIterator> pvi(prhs->getArray());
            while(pvi->more()) {
                intrusive_ptr<const Value> pElement(pvi->next());
                vpValue.push_back(pElement);
            }
        }

        return Value::getNull();
    }
Example #3
0
void scan_airspaces(const AircraftState state,
                    const Airspaces& airspaces,
                    const AirspaceAircraftPerformance& perf,
                    bool do_report,
                    const GeoPoint &target)
{
    const fixed range(20000.0);

    Directory::Create(Path(_T("output/results")));

    {
        AirspaceVisitorPrint pvisitor("output/results/res-bb-range.txt",
                                      do_report);
        for (const auto &i : airspaces.QueryWithinRange(state.location, range)) {
            const AbstractAirspace &airspace = i.GetAirspace();
            pvisitor.Visit(airspace);
        }
    }

    {
        AirspaceVisitorClosest pvisitor("output/results/res-bb-closest.txt",
                                        airspaces.GetProjection(), state, perf);
        for (const auto &i : airspaces.QueryWithinRange(state.location, range)) {
            const AbstractAirspace &airspace = i.GetAirspace();
            pvisitor.Visit(airspace);
        }
    }

    {
        AirspaceVisitorPrint pvi("output/results/res-bb-inside.txt",
                                 do_report);
        for (const auto &a : airspaces.QueryInside(state))
            pvi.Visit(a.GetAirspace());
    }

    {
        AirspaceIntersectionVisitorPrint ivisitor("output/results/res-bb-intersects.txt",
                "output/results/res-bb-intersected.txt",
                "output/results/res-bb-intercepts.txt",
                do_report,
                state, perf);
        airspaces.VisitIntersecting(state.location, target, ivisitor);
    }

    {
        const auto *as = FindSoonestAirspace(airspaces, state, perf,
                                             AirspacePredicateTrue());
        if (do_report) {
            std::ofstream fout("output/results/res-bb-sortedsoonest.txt");
            if (as) {
                fout << *as << "\n";
            } else {
                fout << "# no soonest found\n";
            }
        }
    }
}
Example #4
0
void scan_airspaces(const AircraftState state, 
                    const Airspaces& airspaces,
                    const AirspaceAircraftPerformance& perf,
                    bool do_report,
                    const GeoPoint &target) 
{
  const fixed range(20000.0);

  Directory::Create(Path(_T("output/results")));

  {
    AirspaceVisitorPrint pvisitor("output/results/res-bb-range.txt",
                                  do_report);
    airspaces.VisitWithinRange(state.location, range, pvisitor);
  }

  {
    AirspaceVisitorClosest pvisitor("output/results/res-bb-closest.txt",
                                    airspaces.GetProjection(), state, perf);
    airspaces.VisitWithinRange(state.location, range, pvisitor);
  }

  {
    const std::vector<Airspace> vi = airspaces.FindInside(state);
    AirspaceVisitorPrint pvi("output/results/res-bb-inside.txt",
                             do_report);
    std::for_each(vi.begin(), vi.end(), CallVisitor<AirspaceVisitor>(pvi));
  }
  
  {
    AirspaceIntersectionVisitorPrint ivisitor("output/results/res-bb-intersects.txt",
                                              "output/results/res-bb-intersected.txt",
                                              "output/results/res-bb-intercepts.txt",
                                              do_report,
                                              state, perf);
    airspaces.VisitIntersecting(state.location, target, ivisitor);
  }

  {
    const auto *as = FindSoonestAirspace(airspaces, state, perf,
                                         AirspacePredicateTrue());
    if (do_report) {
      std::ofstream fout("output/results/res-bb-sortedsoonest.txt");
      if (as) {
        fout << *as << "\n";
      } else {
        fout << "# no soonest found\n";
      }
    }
  }
}
Example #5
0
void scan_airspaces(const AircraftState state,
                    const Airspaces& airspaces,
                    const AirspaceAircraftPerformance& perf,
                    bool do_report,
                    const GeoPoint &target)
{
    const fixed range(20000.0);

    Directory::Create(_T("output/results"));
    AirspaceVisitorPrint pvn("output/results/res-bb-nearest.txt",
                             do_report);
    const Airspace *nearest = airspaces.FindNearest(state.location);
    if (nearest != nullptr) {
        AirspaceVisitor &v = pvn;
        v.Visit(*nearest);
    }

    {
        AirspaceVisitorPrint pvisitor("output/results/res-bb-range.txt",
                                      do_report);
        airspaces.VisitWithinRange(state.location, range, pvisitor);
    }

    {
        AirspaceVisitorClosest pvisitor("output/results/res-bb-closest.txt",
                                        airspaces.GetProjection(), state, perf);
        airspaces.VisitWithinRange(state.location, range, pvisitor);
    }

    {
        const std::vector<Airspace> vi = airspaces.FindInside(state);
        AirspaceVisitorPrint pvi("output/results/res-bb-inside.txt",
                                 do_report);
        std::for_each(vi.begin(), vi.end(), CallVisitor<AirspaceVisitor>(pvi));
    }

    {
        AirspaceIntersectionVisitorPrint ivisitor("output/results/res-bb-intersects.txt",
                "output/results/res-bb-intersected.txt",
                "output/results/res-bb-intercepts.txt",
                do_report,
                state, perf);
        airspaces.VisitIntersecting(state.location, target, ivisitor);
    }

    {
        AirspaceNearestSort ans(state.location);
        const AbstractAirspace* as = ans.find_nearest(airspaces, range);
        if (do_report) {
            std::ofstream fout("output/results/res-bb-sortednearest.txt");
            if (as) {
                fout << *as << "\n";
            } else {
                fout << "# no nearest found\n";
            }
        }
    }

    {
        AirspaceSoonestSort ans(state, perf);
        const AbstractAirspace* as = ans.find_nearest(airspaces);
        if (do_report) {
            std::ofstream fout("output/results/res-bb-sortedsoonest.txt");
            if (as) {
                fout << *as << "\n";
            } else {
                fout << "# no soonest found\n";
            }
        }
    }
}
Example #6
0
void scan_airspaces(const AIRCRAFT_STATE state, 
                    const Airspaces& airspaces,
                    const AirspaceAircraftPerformance& perf,
                    bool do_report,
                    const GeoPoint &target) 
{
  const fixed range(20000.0);

  const std::vector<Airspace> vn = airspaces.scan_nearest(state.Location);
  AirspaceVisitorPrint pvn("results/res-bb-nearest.txt",
                           do_report);
  std::for_each(vn.begin(), vn.end(), CallVisitor<AirspaceVisitor>(pvn));

  {
    AirspaceVisitorPrint pvisitor("results/res-bb-range.txt",
                                  do_report);
    airspaces.visit_within_range(state.Location, range, pvisitor);
  }

  {
    AirspaceVisitorClosest pvisitor("results/res-bb-closest.txt",
                                    state, perf);
    airspaces.visit_within_range(state.Location, range, pvisitor);
  }

  {
    const std::vector<Airspace> vi = airspaces.find_inside(state);
    AirspaceVisitorPrint pvi("results/res-bb-inside.txt",
                             do_report);
    std::for_each(vi.begin(), vi.end(), CallVisitor<AirspaceVisitor>(pvi));
  }
  
  {
    AirspaceIntersectionVisitorPrint ivisitor("results/res-bb-intersects.txt",
                                              "results/res-bb-intersected.txt",
                                              "results/res-bb-intercepts.txt",
                                              do_report,
                                              state, perf);
    GeoVector vec(state.Location, target);
    airspaces.visit_intersecting(state.Location, vec, ivisitor);
  }

  {
    AirspaceNearestSort ans(state.Location);
    const AbstractAirspace* as = ans.find_nearest(airspaces, range);
    if (do_report) {
      std::ofstream fout("results/res-bb-sortednearest.txt");
      if (as) {
        fout << *as << "\n";
      } else {
        fout << "# no nearest found\n";
      }
    }
  }

  {
    AirspaceSoonestSort ans(state, perf);
    const AbstractAirspace* as = ans.find_nearest(airspaces);
    if (do_report) {
      std::ofstream fout("results/res-bb-sortedsoonest.txt");
      if (as) {
        fout << *as << "\n";
      } else {
        fout << "# no soonest found\n";
      }
    }
  }

}