idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
3,000 | public boolean removeExecutedTradeCallback ( final BitfinexExecutedTradeSymbol tradeSymbol , final BiConsumer < BitfinexExecutedTradeSymbol , BitfinexExecutedTrade > callback ) throws BitfinexClientException { return tradesCallbacks . removeCallback ( tradeSymbol , callback ) ; } | Remove a executed trade callback |
3,001 | public FutureOperation subscribeExecutedTrades ( final BitfinexExecutedTradeSymbol tradeSymbol ) { final FutureOperation future = new FutureOperation ( tradeSymbol ) ; pendingSubscribes . registerFuture ( future ) ; final SubscribeTradesCommand subscribeOrderbookCommand = new SubscribeTradesCommand ( tradeSymbol ) ; cl... | Subscribe a executed trade channel |
3,002 | public FutureOperation unsubscribeExecutedTrades ( final BitfinexExecutedTradeSymbol tradeSymbol ) { final FutureOperation future = new FutureOperation ( tradeSymbol ) ; pendingUnsubscribes . registerFuture ( future ) ; final UnsubscribeChannelCommand command = new UnsubscribeChannelCommand ( tradeSymbol ) ; client . s... | Unsubscribe a executed trades channel |
3,003 | public static void registerDefaults ( ) throws BitfinexClientException { try { final URL url = new URL ( SYMBOL_URL ) ; final String symbolJson = Resources . toString ( url , Charsets . UTF_8 ) ; final JSONArray jsonArray = new JSONArray ( symbolJson ) ; for ( int i = 0 ; i < jsonArray . length ( ) ; i ++ ) { final JSO... | Load and register all known currencies |
3,004 | public static BitfinexCurrencyPair register ( final String currency , final String profitCurrency , final double minimalOrderSize ) { final String key = buildCacheKey ( currency , profitCurrency ) ; final BitfinexCurrencyPair newCurrency = new BitfinexCurrencyPair ( currency , profitCurrency , minimalOrderSize ) ; fina... | Registers currency pair for use within library |
3,005 | public static BitfinexCurrencyPair of ( final String currency , final String profitCurrency ) { final String key = buildCacheKey ( currency , profitCurrency ) ; final BitfinexCurrencyPair bcp = instances . get ( key ) ; if ( bcp == null ) { throw new IllegalArgumentException ( "CurrencyPair is not registered: " + curre... | Retrieves bitfinex currency pair |
3,006 | public static BitfinexCurrencyPair fromSymbolString ( final String symbolString ) { for ( final BitfinexCurrencyPair currency : BitfinexCurrencyPair . values ( ) ) { if ( currency . toBitfinexString ( ) . equalsIgnoreCase ( symbolString ) ) { return currency ; } } throw new IllegalArgumentException ( "Unable to find cu... | Construct from string |
3,007 | public void registerCallback ( final S symbol , final BiConsumer < S , T > callback ) throws BitfinexClientException { final List < BiConsumer < S , T > > callbackList = callbacks . computeIfAbsent ( symbol , ( k ) -> new CopyOnWriteArrayList < > ( ) ) ; callbackList . add ( callback ) ; } | Register a new callback |
3,008 | public boolean removeCallback ( final S symbol , final BiConsumer < S , T > callback ) throws BitfinexClientException { final List < BiConsumer < S , T > > callbackList = callbacks . get ( symbol ) ; if ( callbackList == null ) { throw new BitfinexClientException ( "Unknown ticker string: " + symbol ) ; } return callba... | Remove the a callback |
3,009 | public void handleEventsCollection ( final S symbol , final Collection < T > elements ) { final List < BiConsumer < S , T > > callbackList = callbacks . get ( symbol ) ; if ( callbackList == null ) { return ; } if ( callbackList . isEmpty ( ) ) { return ; } for ( final T element : elements ) { callbackList . forEach ( ... | Process a list with event |
3,010 | public static BitfinexInstrument build ( final String symbolString ) { if ( symbolString . startsWith ( "t" ) ) { return BitfinexCurrencyPair . fromSymbolString ( symbolString ) ; } else if ( symbolString . startsWith ( "f" ) ) { return BitfinexFundingCurrency . fromSymbolString ( symbolString ) ; } else { throw new Il... | Build the bitfinex currency from sybol string |
3,011 | public void registerOrderbookCallback ( final BitfinexOrderBookSymbol orderbookConfiguration , final BiConsumer < BitfinexOrderBookSymbol , BitfinexOrderBookEntry > callback ) throws BitfinexClientException { channelCallbacks . registerCallback ( orderbookConfiguration , callback ) ; } | Register a new trading orderbook callback |
3,012 | public void connect ( ) throws DeploymentException , IOException , InterruptedException { final WebSocketContainer container = ContainerProvider . getWebSocketContainer ( ) ; connectLatch = new CountDownLatch ( 1 ) ; this . userSession = container . connectToServer ( this , endpointURI ) ; connectLatch . await ( 15 , T... | Open a new connection and wait until connection is ready |
3,013 | public void sendMessage ( final String message ) { if ( userSession == null ) { logger . error ( "Unable to send message, user session is null" ) ; return ; } if ( userSession . getAsyncRemote ( ) == null ) { logger . error ( "Unable to send message, async remote is null" ) ; return ; } userSession . getAsyncRemote ( )... | Send a new message to the server |
3,014 | public void auditPackage ( final JSONArray jsonArray ) { final long channelId = jsonArray . getInt ( 0 ) ; final boolean isHeartbeat = jsonArray . optString ( 1 , "" ) . equals ( "hb" ) ; if ( channelId == 0 ) { if ( isHeartbeat ) { checkPublicSequence ( jsonArray ) ; } else { checkPublicAndPrivateSequence ( jsonArray ... | Audit the package |
3,015 | private void checkPublicAndPrivateSequence ( final JSONArray jsonArray ) { final long nextPublicSequnceNumber = jsonArray . getLong ( jsonArray . length ( ) - 2 ) ; final long nextPrivateSequnceNumber = jsonArray . getLong ( jsonArray . length ( ) - 1 ) ; auditPublicSequence ( nextPublicSequnceNumber ) ; auditPrivateSe... | Check the public and the private sequence |
3,016 | private void checkPublicSequence ( final JSONArray jsonArray ) { final long nextPublicSequnceNumber = jsonArray . getLong ( jsonArray . length ( ) - 1 ) ; auditPublicSequence ( nextPublicSequnceNumber ) ; } | Check the public sequence |
3,017 | private void auditPublicSequence ( final long nextPublicSequnceNumber ) { if ( publicSequence == - 1 ) { publicSequence = nextPublicSequnceNumber ; return ; } if ( publicSequence + 1 != nextPublicSequnceNumber ) { final String errorMessage = String . format ( "Got %d as next public sequence number, expected %d", publ... | Audit the public sequence |
3,018 | private void auditPrivateSequence ( final long nextPrivateSequnceNumber ) { if ( privateSequence == - 1 ) { privateSequence = nextPrivateSequnceNumber ; return ; } if ( privateSequence + 1 != nextPrivateSequnceNumber ) { final String errorMessage = String . format ( "Got %d as next private sequence number, expected %d"... | Audit the private sequence |
3,019 | private void handleError ( final String errorMessage ) { failed = true ; switch ( errorPolicy ) { case LOG_ONLY : logger . error ( errorMessage ) ; break ; case RUNTIME_EXCEPTION : throw new RuntimeException ( errorMessage ) ; default : logger . error ( "Got error {} but unkown error policy {}" , errorMessage , errorPo... | Handle the sequence number error |
3,020 | public static BitfinexOrderBookSymbol fromJSON ( final JSONObject jsonObject ) { BitfinexCurrencyPair symbol = BitfinexCurrencyPair . fromSymbolString ( jsonObject . getString ( "symbol" ) ) ; Precision prec = Precision . valueOf ( jsonObject . getString ( "prec" ) ) ; Frequency freq = null ; Integer len = null ; if ( ... | Build from JSON Array |
3,021 | public static LocalCall < List < Record > > records ( RecordType type ) { Map < String , Object > args = new LinkedHashMap < > ( ) ; if ( type != null ) { args . put ( "rec_type" , type . getType ( ) ) ; } args . put ( "clean" , false ) ; return new LocalCall < > ( "smbios.records" , Optional . empty ( ) , Optional . o... | smbios . records |
3,022 | public static LocalCall < String > get ( String key ) { return new LocalCall < > ( "config.get" , Optional . of ( Arrays . asList ( key ) ) , Optional . empty ( ) , new TypeToken < String > ( ) { } ) ; } | Returns a configuration parameter . |
3,023 | public static ParameterizedType parameterizedType ( Type ownerType , Type rawType , Type ... typeArguments ) { return newParameterizedTypeWithOwner ( ownerType , rawType , typeArguments ) ; } | Helper for constructing parameterized types . |
3,024 | public CompletionStage < WheelAsyncResult < R > > callAsync ( final SaltClient client , AuthMethod auth ) { return client . call ( this , Client . WHEEL_ASYNC , Optional . empty ( ) , Collections . emptyMap ( ) , new TypeToken < Return < List < WheelAsyncResult < R > > > > ( ) { } , auth ) . thenApply ( wrapper -> { Wh... | Calls a wheel module function on the master asynchronously and returns information about the scheduled job that can be used to query the result . Authentication is done with the token therefore you have to login prior to using this function . |
3,025 | public CompletionStage < WheelResult < Result < R > > > callSync ( final SaltClient client , AuthMethod auth ) { Type xor = parameterizedType ( null , Result . class , getReturnType ( ) . getType ( ) ) ; Type wheelResult = parameterizedType ( null , WheelResult . class , xor ) ; Type listType = parameterizedType ( null... | Calls a wheel module function on the master and synchronously waits for the result . Authentication is done with the token therefore you have to login prior to using this function . |
3,026 | public static void mapConfigPropsToArgs ( SaltSSHConfig cfg , Map < String , Object > props ) { cfg . getExtraFilerefs ( ) . ifPresent ( v -> props . put ( "extra_filerefs" , v ) ) ; cfg . getIdentitiesOnly ( ) . ifPresent ( v -> props . put ( "ssh_identities_only" , v ) ) ; cfg . getIgnoreHostKeys ( ) . ifPresent ( v ... | Maps config parameters to salt - ssh rest arguments |
3,027 | public void onMessage ( String partialMessage , boolean last ) throws MessageTooBigException { if ( partialMessage . length ( ) > maxMessageLength - messageBuffer . length ( ) ) { throw new MessageTooBigException ( maxMessageLength ) ; } if ( last ) { String message ; if ( messageBuffer . length ( ) == 0 ) { message = ... | Notify listeners on each event received on the websocket and buffer partial messages . |
3,028 | public void onClose ( Session session , CloseReason closeReason ) { this . session = session ; clearListeners ( closeReason . getCloseCode ( ) . getCode ( ) , closeReason . getReasonPhrase ( ) ) ; } | On closing the websocket refresh the session and notify all subscribed listeners . Upon exit from this method all subscribed listeners will be removed . |
3,029 | private Map < String , Object > readObjectArgument ( JsonReader jsonReader ) throws IOException { Map < String , Object > arg = new LinkedHashMap < > ( ) ; jsonReader . beginObject ( ) ; while ( jsonReader . hasNext ( ) ) { arg . put ( jsonReader . nextName ( ) , JsonParser . GSON . fromJson ( jsonReader , Object . cla... | Reads a generic object argument from the given JsonReader . |
3,030 | public < R > R getData ( TypeToken < R > type ) { return GSON . fromJson ( data , type . getType ( ) ) ; } | Return the event data parsed into the given type . |
3,031 | public Map < String , Object > getData ( ) { TypeToken < Map < String , Object > > typeToken = new TypeToken < Map < String , Object > > ( ) { } ; return getData ( typeToken ) ; } | Return event data as Map |
3,032 | public static LocalCall < Result > add ( String name , LocalCall < ? > call , LocalDateTime once , Map < String , ? > metadata ) { LinkedHashMap < String , Object > args = new LinkedHashMap < > ( ) ; Map < String , Object > payload = call . getPayload ( ) ; args . put ( "function" , payload . get ( "fun" ) ) ; args . p... | Schedule a salt call for later execution on the minion |
3,033 | private < L , R > TypeAdapter < Xor < L , R > > xorAdapter ( TypeAdapter < L > leftAdapter , TypeAdapter < R > rightAdapter ) { return new TypeAdapter < Xor < L , R > > ( ) { public Xor < L , R > read ( JsonReader in ) throws IOException { JsonElement json = TypeAdapters . JSON_ELEMENT . read ( in ) ; try { R value = r... | Creates a generic Xor adapter by combining two other adapters - one for each side of the Xor type . It will first try to parse incoming JSON data as the right type and if that does not succeed it will try again with the left type . |
3,034 | private < R > TypeAdapter < Xor < SaltError , R > > errorAdapter ( TypeAdapter < R > innerAdapter ) { return new TypeAdapter < Xor < SaltError , R > > ( ) { public Xor < SaltError , R > read ( JsonReader in ) throws IOException { JsonElement json = TypeAdapters . JSON_ELEMENT . read ( in ) ; try { R value = innerAdapte... | Creates a Xor adapter specifically for the case in which the left side is a SaltError . This is used to catch any Salt - side or JSON parsing errors . |
3,035 | private < T > CompletionStage < T > request ( URI uri , Map < String , String > headers , String data , JsonParser < T > parser ) { return executeRequest ( httpClient , prepareRequest ( uri , headers , data ) , parser ) ; } | Perform HTTP request and parse the result into a given result type . |
3,036 | private < T > HttpUriRequest prepareRequest ( URI uri , Map < String , String > headers , String jsonData ) { HttpUriRequest httpRequest ; if ( jsonData != null ) { HttpPost httpPost = new HttpPost ( uri ) ; httpPost . setEntity ( new StringEntity ( jsonData , ContentType . APPLICATION_JSON ) ) ; httpRequest = httpPost... | Prepares the HTTP request object creating a POST or GET request depending on if data is supplied or not . |
3,037 | private < T > CompletionStage < T > executeRequest ( HttpAsyncClient httpClient , HttpUriRequest httpRequest , JsonParser < T > parser ) { CompletableFuture < T > future = new CompletableFuture < > ( ) ; httpClient . execute ( httpRequest , new FutureCallback < HttpResponse > ( ) { public void failed ( Exception e ) { ... | Executes a prepared HTTP request using the given client . |
3,038 | public < R > R getData ( TypeToken < R > dataType ) { return GSON . fromJson ( data , dataType . getType ( ) ) ; } | Return this event s data . |
3,039 | public Map < String , Object > getData ( ) { TypeToken < Map < String , Object > > typeToken = new TypeToken < Map < String , Object > > ( ) { } ; return GSON . fromJson ( data , typeToken . getType ( ) ) ; } | Return this event s data as a Map |
3,040 | public static LocalCall < String > chown ( String path , String user , String group ) { Map < String , String > args = new LinkedHashMap < > ( ) ; args . put ( "path" , path ) ; args . put ( "user" , user ) ; args . put ( "group" , group ) ; return new LocalCall < > ( "file.chown" , Optional . empty ( ) , Optional . of... | Chown a file |
3,041 | public static LocalCall < String > chmod ( String path , String mode ) { return new LocalCall < > ( "file.set_mode" , Optional . of ( Arrays . asList ( path , mode ) ) , Optional . empty ( ) , new TypeToken < String > ( ) { } ) ; } | Set the mode of a file |
3,042 | public static LocalCall < Boolean > copy ( String src , String dst , boolean recurse , boolean removeExisting ) { Map < String , Object > args = new LinkedHashMap < > ( ) ; args . put ( "src" , src ) ; args . put ( "dst" , dst ) ; args . put ( "recurse" , recurse ) ; args . put ( "remove_existing" , removeExisting ) ; ... | Copy a file or directory from src to dst |
3,043 | public static LocalCall < Result > move ( String src , String dst ) { Map < String , Object > args = new LinkedHashMap < > ( ) ; args . put ( "src" , src ) ; args . put ( "dst" , dst ) ; return new LocalCall < > ( "file.move" , Optional . empty ( ) , Optional . of ( args ) , new TypeToken < Result > ( ) { } ) ; } | Move a file or directory from src to dst |
3,044 | public static LocalCall < String > getHash ( String path , HashType form ) { return getHash ( path , Optional . of ( form ) , Optional . empty ( ) ) ; } | Get the hash sum of a file |
3,045 | public static LocalCall < String > getUid ( String path , boolean followSymlinks ) { Map < String , Object > args = new LinkedHashMap < > ( ) ; args . put ( "path" , path ) ; args . put ( "follow_symlinks" , followSymlinks ) ; return new LocalCall < > ( "file.get_uid" , Optional . empty ( ) , Optional . of ( args ) , n... | Return the id of the user that owns a given file |
3,046 | public static LocalCall < List < String > > readdir ( String path ) { return new LocalCall < > ( "file.readdir" , Optional . of ( Collections . singletonList ( path ) ) , Optional . empty ( ) , new TypeToken < List < String > > ( ) { } ) ; } | Returns a list containing the contents of a directory |
3,047 | public static LocalCall < Map < String , List < Xor < String , Info > > > > listPkgs ( List < String > attributes ) { LinkedHashMap < String , Object > args = new LinkedHashMap < > ( ) ; args . put ( "attr" , attributes ) ; return new LocalCall < > ( "pkg.list_pkgs" , Optional . empty ( ) , Optional . of ( args ) , new... | Call pkg . list_pkgs |
3,048 | public static LocalCall < Map < String , Xor < Info , List < Info > > > > infoInstalledAllVersions ( List < String > attributes , boolean reportErrors , String ... packages ) { LinkedHashMap < String , Object > kwargs = new LinkedHashMap < > ( ) ; kwargs . put ( "attr" , attributes . stream ( ) . collect ( Collectors .... | Call pkg . info_installed API . |
3,049 | public T parse ( InputStream inputStream ) { Reader inputStreamReader = new InputStreamReader ( inputStream ) ; Reader streamReader = new BufferedReader ( inputStreamReader ) ; return gson . fromJson ( streamReader , type . getType ( ) ) ; } | Parses a Json response that has a direct representation as a Java class . |
3,050 | public static CloseableHttpAsyncClient defaultClient ( ) { RequestConfig requestConfig = RequestConfig . custom ( ) . setConnectionRequestTimeout ( 0 ) . setConnectTimeout ( 10000 ) . setSocketTimeout ( 20000 ) . setCookieSpec ( CookieSpecs . STANDARD ) . build ( ) ; HttpAsyncClientBuilder httpClientBuilder = HttpAsync... | Creates a simple default http client |
3,051 | public static Optional < SaltVersion > parse ( String versionString ) { Matcher matcher = SALT_VERSION_REGEX . matcher ( versionString ) ; if ( matcher . matches ( ) ) { int year = Integer . parseInt ( matcher . group ( 1 ) ) ; int month = Integer . parseInt ( matcher . group ( 2 ) ) ; int bugfix = Integer . parseInt (... | Parses a salt version string |
3,052 | protected void clearListeners ( int code , String phrase ) { listeners . forEach ( listener -> listener . eventStreamClosed ( code , phrase ) ) ; listeners . clear ( ) ; } | Removes all listeners . |
3,053 | public < R > Change < R > map ( Function < T , R > fn ) { return new Change < > ( fn . apply ( getOldValue ( ) ) , fn . apply ( getNewValue ( ) ) ) ; } | Applies a mapping function to both the old and the new value wrapping the result in a new Change . |
3,054 | public CompletionStage < Map < String , Result < R > > > callSync ( final SaltClient client , Target < ? > target , AuthMethod auth ) { return callSyncHelperNonBlock ( client , target , auth , Optional . empty ( ) ) . thenApply ( r -> r . get ( 0 ) ) ; } | Calls a execution module function on the given target and synchronously waits for the result . Authentication is done with the token therefore you have to login prior to using this function . |
3,055 | public CompletionStage < List < Map < String , Result < R > > > > callSync ( final SaltClient client , Target < ? > target , AuthMethod auth , Optional < Batch > batch ) { return callSyncHelperNonBlock ( client , target , auth , batch ) ; } | Calls a execution module function on the given target with batching and synchronously waits for the result . Authentication is done with the token therefore you have to login prior to using this function . |
3,056 | private List < Map < String , Result < R > > > handleRetcodeBatchingHack ( List < Map < String , Result < R > > > list , Type xor ) { return list . stream ( ) . map ( m -> { return m . entrySet ( ) . stream ( ) . collect ( Collectors . toMap ( e -> e . getKey ( ) , e -> { return e . getValue ( ) . fold ( err -> { retur... | specific to how a function is dispatched . |
3,057 | private CompletionStage < List < Map < String , Result < R > > > > callSyncHelperNonBlock ( final SaltClient client , Target < ? > target , AuthMethod auth , Optional < Batch > batch ) { Map < String , Object > customArgs = new HashMap < > ( ) ; batch . ifPresent ( v -> customArgs . putAll ( v . getParams ( ) ) ) ; Cli... | Helper to call an execution module function on the given target for batched or unbatched while also providing an option to use the given credentials or to use a prior created token . Synchronously waits for the result . |
3,058 | public CompletionStage < Map < String , Result < SSHResult < R > > > > callSyncSSH ( final SaltClient client , SSHTarget < ? > target , SaltSSHConfig cfg , AuthMethod auth ) { Map < String , Object > args = new HashMap < > ( ) ; args . putAll ( getPayload ( ) ) ; args . putAll ( target . getProps ( ) ) ; SaltSSHUtils .... | Call an execution module function on the given target via salt - ssh and synchronously wait for the result . |
3,059 | public long getPolyRefBase ( MeshTile tile ) { if ( tile == null ) { return 0 ; } int it = tile . index ; return encodePolyId ( tile . salt , it , 0 ) ; } | Gets the polygon reference for the tile s base polygon . |
3,060 | public static long encodePolyId ( int salt , int it , int ip ) { return ( ( ( long ) salt ) << ( DT_POLY_BITS + DT_TILE_BITS ) ) | ( ( long ) it << DT_POLY_BITS ) | ip ; } | Derives a standard polygon reference . |
3,061 | public int [ ] calcTileLoc ( float [ ] pos ) { int tx = ( int ) Math . floor ( ( pos [ 0 ] - m_orig [ 0 ] ) / m_tileWidth ) ; int ty = ( int ) Math . floor ( ( pos [ 2 ] - m_orig [ 2 ] ) / m_tileHeight ) ; return new int [ ] { tx , ty } ; } | Calculates the tile grid location for the specified world position . |
3,062 | void baseOffMeshLinks ( MeshTile tile ) { if ( tile == null ) { return ; } long base = getPolyRefBase ( tile ) ; for ( int i = 0 ; i < tile . data . header . offMeshConCount ; ++ i ) { OffMeshConnection con = tile . data . offMeshCons [ i ] ; Poly poly = tile . data . polys [ con . poly ] ; float [ ] ext = new float [ ... | Builds internal polygons links for a tile . |
3,063 | float [ ] closestPointOnDetailEdges ( MeshTile tile , Poly poly , float [ ] pos , boolean onlyBoundary ) { int ANY_BOUNDARY_EDGE = ( DT_DETAIL_EDGE_BOUNDARY << 0 ) | ( DT_DETAIL_EDGE_BOUNDARY << 2 ) | ( DT_DETAIL_EDGE_BOUNDARY << 4 ) ; int ip = poly . index ; PolyDetail pd = tile . data . detailMeshes [ ip ] ; float dm... | Returns closest point on polygon . |
3,064 | List < Integer > convexhull ( List < Float > pts ) { int npts = pts . size ( ) / 3 ; List < Integer > out = new ArrayList < > ( ) ; int hull = 0 ; for ( int i = 1 ; i < npts ; ++ i ) { float [ ] a = new float [ ] { pts . get ( i * 3 ) , pts . get ( i * 3 + 1 ) , pts . get ( i * 3 + 2 ) } ; float [ ] b = new float [ ] {... | returns number of points on hull . |
3,065 | boolean cmppt ( float [ ] a , float [ ] b ) { if ( a [ 0 ] < b [ 0 ] ) { return true ; } if ( a [ 0 ] > b [ 0 ] ) { return false ; } if ( a [ 2 ] < b [ 2 ] ) { return true ; } if ( a [ 2 ] > b [ 2 ] ) { return false ; } return false ; } | Returns true if a is more lower - left than b . |
3,066 | boolean left ( float [ ] a , float [ ] b , float [ ] c ) { float u1 = b [ 0 ] - a [ 0 ] ; float v1 = b [ 2 ] - a [ 2 ] ; float u2 = c [ 0 ] - a [ 0 ] ; float v2 = c [ 2 ] - a [ 2 ] ; return u1 * v2 - v1 * u2 < 0 ; } | Returns true if c is left of line a - b . |
3,067 | public void reset ( long ref , float [ ] pos ) { m_path . clear ( ) ; m_path . add ( ref ) ; vCopy ( m_pos , pos ) ; vCopy ( m_target , pos ) ; } | Resets the path corridor to the specified position . |
3,068 | public void optimizePathVisibility ( float [ ] next , float pathOptimizationRange , NavMeshQuery navquery , QueryFilter filter ) { float dist = vDist2D ( m_pos , next ) ; if ( dist < 0.01f ) { return ; } dist = Math . min ( dist + 0.01f , pathOptimizationRange ) ; float [ ] delta = vSub ( next , m_pos ) ; float [ ] goa... | Attempts to optimize the path if the specified point is visible from the current position . |
3,069 | public boolean movePosition ( float [ ] npos , NavMeshQuery navquery , QueryFilter filter ) { Result < MoveAlongSurfaceResult > masResult = navquery . moveAlongSurface ( m_path . get ( 0 ) , m_pos , npos , filter ) ; if ( masResult . succeeded ( ) ) { m_path = mergeCorridorStartMoved ( m_path , masResult . result . get... | Moves the position from the current location to the desired location adjusting the corridor as needed to reflect the change . |
3,070 | public void setCorridor ( float [ ] target , List < Long > path ) { vCopy ( m_target , target ) ; m_path = new ArrayList < > ( path ) ; } | Loads a new path and target into the corridor . The current corridor position is expected to be within the first polygon in the path . The target is expected to be in the last polygon . |
3,071 | public static int findEdge ( Poly node , Poly neighbour , MeshData tile , MeshData neighbourTile ) { for ( int i = 0 ; i < node . vertCount ; i ++ ) { int j = ( i + 1 ) % node . vertCount ; for ( int k = 0 ; k < neighbour . vertCount ; k ++ ) { int l = ( k + 1 ) % neighbour . vertCount ; if ( ( node . verts [ i ] == ne... | Find edge shared by 2 polygons within the same tile |
3,072 | public static int findEdge ( Poly node , MeshData tile , float value , int comp ) { float error = Float . MAX_VALUE ; int edge = 0 ; for ( int i = 0 ; i < node . vertCount ; i ++ ) { int j = ( i + 1 ) % node . vertCount ; float v1 = tile . verts [ 3 * node . verts [ i ] + comp ] - value ; float v2 = tile . verts [ 3 * ... | Find edge closest to the given coordinate |
3,073 | void build ( int nodeOffset , GraphMeshData graphData , List < int [ ] > connections ) { for ( int n = 0 ; n < connections . size ( ) ; n ++ ) { int [ ] nodeConnections = connections . get ( n ) ; MeshData tile = graphData . getTile ( n ) ; Poly node = graphData . getNode ( n ) ; for ( int connection : nodeConnections ... | Process connections and transform them into recast neighbour flags |
3,074 | private void buildExternalLink ( MeshData tile , Poly node , MeshData neighbourTile ) { if ( neighbourTile . header . bmin [ 0 ] > tile . header . bmin [ 0 ] ) { node . neis [ PolyUtils . findEdge ( node , tile , neighbourTile . header . bmin [ 0 ] , 0 ) ] = NavMesh . DT_EXT_LINK ; } else if ( neighbourTile . header . ... | In case of external link to other tiles we must find the direction |
3,075 | private static int [ ] findLeftMostVertex ( Contour contour ) { int minx = contour . verts [ 0 ] ; int minz = contour . verts [ 2 ] ; int leftmost = 0 ; for ( int i = 1 ; i < contour . nverts ; i ++ ) { int x = contour . verts [ i * 4 + 0 ] ; int z = contour . verts [ i * 4 + 2 ] ; if ( x < minx || ( x == minx && z < m... | Finds the lowest leftmost vertex of a contour . |
3,076 | public Result < List < Long > > queryPolygons ( float [ ] center , float [ ] halfExtents , QueryFilter filter ) { if ( Objects . isNull ( center ) || ! vIsFinite ( center ) || Objects . isNull ( halfExtents ) || ! vIsFinite ( halfExtents ) || Objects . isNull ( filter ) ) { } float [ ] bmin = vSub ( center , halfExtent... | Finds polygons that overlap the search box . |
3,077 | public Status initSlicedFindPath ( long startRef , long endRef , float [ ] startPos , float [ ] endPos , QueryFilter filter , int options ) { m_query = new QueryData ( ) ; m_query . status = Status . FAILURE ; m_query . startRef = startRef ; m_query . endRef = endRef ; vCopy ( m_query . startPos , startPos ) ; vCopy ( ... | Intializes a sliced path query . |
3,078 | protected Result < float [ ] > getEdgeMidPoint ( long from , long to ) { Result < PortalResult > ppoints = getPortalPoints ( from , to ) ; if ( ppoints . failed ( ) ) { return Result . of ( ppoints . status , ppoints . message ) ; } float [ ] left = ppoints . result . left ; float [ ] right = ppoints . result . right ;... | Returns edge mid point between two polygons . |
3,079 | public Result < List < Long > > getPathFromDijkstraSearch ( long endRef ) { if ( ! m_nav . isValidPolyRef ( endRef ) ) { return Result . invalidParam ( "Invalid end ref" ) ; } List < Node > nodes = m_nodePool . findNodes ( endRef ) ; if ( nodes . size ( ) != 1 ) { return Result . invalidParam ( "Invalid end ref" ) ; } ... | Gets a path from the explored nodes in the previous search . |
3,080 | private List < Long > getPathToNode ( Node endNode ) { List < Long > path = new ArrayList < > ( ) ; Node curNode = endNode ; do { path . add ( 0 , curNode . id ) ; curNode = m_nodePool . getNodeAtIdx ( curNode . pidx ) ; } while ( curNode != null ) ; return path ; } | Gets the path leading to the specified end node . |
3,081 | public boolean update ( ) { if ( m_update . isEmpty ( ) ) { for ( ObstacleRequest req : m_reqs ) { int idx = decodeObstacleIdObstacle ( req . ref ) ; if ( idx >= m_obstacles . size ( ) ) { continue ; } TileCacheObstacle ob = m_obstacles . get ( idx ) ; int salt = decodeObstacleIdSalt ( req . ref ) ; if ( ob . salt != s... | Updates the tile cache by rebuilding tiles touched by unfinished obstacle requests . |
3,082 | static float [ ] randomPointInConvexPoly ( float [ ] pts , int npts , float [ ] areas , float s , float t ) { float areasum = 0.0f ; for ( int i = 2 ; i < npts ; i ++ ) { areas [ i ] = triArea2D ( pts , 0 , ( i - 1 ) * 3 , i * 3 ) ; areasum += Math . max ( 0.001f , areas [ i ] ) ; } float thr = s * areasum ; float acc ... | Adapted from Graphics Gems article . |
3,083 | private static float polyMinExtent ( float [ ] verts , int nverts ) { float minDist = Float . MAX_VALUE ; for ( int i = 0 ; i < nverts ; i ++ ) { int ni = ( i + 1 ) % nverts ; int p1 = i * 3 ; int p2 = ni * 3 ; float maxEdgeDist = 0 ; for ( int j = 0 ; j < nverts ; j ++ ) { if ( j == i || j == ni ) { continue ; } float... | Calculate minimum extend of the polygon . |
3,084 | static boolean left ( int [ ] verts , int a , int b , int c ) { return area2 ( verts , a , b , c ) < 0 ; } | line through a to b . |
3,085 | private static boolean intersectProp ( int [ ] verts , int a , int b , int c , int d ) { if ( collinear ( verts , a , b , c ) || collinear ( verts , a , b , d ) || collinear ( verts , c , d , a ) || collinear ( verts , c , d , b ) ) return false ; return ( left ( verts , a , b , c ) ^ left ( verts , a , b , d ) ) && ( ... | intersection is ensured by using strict leftness . |
3,086 | private static boolean between ( int [ ] verts , int a , int b , int c ) { if ( ! collinear ( verts , a , b , c ) ) return false ; if ( verts [ a + 0 ] != verts [ b + 0 ] ) return ( ( verts [ a + 0 ] <= verts [ c + 0 ] ) && ( verts [ c + 0 ] <= verts [ b + 0 ] ) ) || ( ( verts [ a + 0 ] >= verts [ c + 0 ] ) && ( verts ... | on the closed segement ab . |
3,087 | static boolean intersect ( int [ ] verts , int a , int b , int c , int d ) { if ( intersectProp ( verts , a , b , c , d ) ) return true ; else if ( between ( verts , a , b , c ) || between ( verts , a , b , d ) || between ( verts , c , d , a ) || between ( verts , c , d , b ) ) return true ; else return false ; } | Returns true iff segments ab and cd intersect properly or improperly . |
3,088 | private static boolean inCone ( int i , int j , int n , int [ ] verts , int [ ] indices ) { int pi = ( indices [ i ] & 0x0fffffff ) * 4 ; int pj = ( indices [ j ] & 0x0fffffff ) * 4 ; int pi1 = ( indices [ next ( i , n ) ] & 0x0fffffff ) * 4 ; int pin1 = ( indices [ prev ( i , n ) ] & 0x0fffffff ) * 4 ; if ( leftOn ( v... | polygon P in the neighborhood of the i endpoint . |
3,089 | private static boolean diagonal ( int i , int j , int n , int [ ] verts , int [ ] indices ) { return inCone ( i , j , n , verts , indices ) && diagonalie ( i , j , n , verts , indices ) ; } | diagonal of P . |
3,090 | public static String encrypt ( String c , String key ) { try { SecretKeySpec skeySpec = new SecretKeySpec ( Hex . decodeHex ( key . toCharArray ( ) ) , "AES" ) ; Cipher cipher = Cipher . getInstance ( "AES" ) ; cipher . init ( Cipher . ENCRYPT_MODE , skeySpec ) ; byte [ ] encoded = cipher . doFinal ( c . getBytes ( ) )... | Encrypts a string . |
3,091 | protected void inject ( Collection < ? extends Expression > objs ) { for ( Object o : objs ) { if ( o == null ) { continue ; } injector . injectMembers ( o ) ; } } | Injects dependencies on the given objects . |
3,092 | protected String join ( Collection < ? > list , String delimiter ) { return Joiner . on ( delimiter ) . join ( list ) ; } | Joins a collection of objects given the delimiter . |
3,093 | public String translate ( final When when ) { inject ( when . condition ) ; inject ( when . action ) ; return String . format ( "WHEN %s THEN %s" , when . condition . translate ( ) , when . action . translate ( ) ) ; } | Translates When . |
3,094 | public String translate ( final Case aCase ) { String elseString = "" ; if ( aCase . getFalseAction ( ) != null ) { inject ( aCase . getFalseAction ( ) ) ; elseString = String . format ( "ELSE %s" , aCase . getFalseAction ( ) . translate ( ) ) ; } final String whens = aCase . whens . stream ( ) . peek ( this :: inject ... | Translates Case . |
3,095 | public String translate ( final Values values ) { final ArrayList < Values . Row > rows = new ArrayList < > ( values . getRows ( ) ) ; final String [ ] aliases = values . getAliases ( ) ; if ( aliases == null || aliases . length == 0 ) { throw new DatabaseEngineRuntimeException ( "Values requires aliases to avoid ambig... | Translates Values . |
3,096 | public String translate ( final Values . Row row ) { inject ( row . getExpressions ( ) ) ; final String translation = row . getExpressions ( ) . stream ( ) . map ( expression -> { final String alias = expression . isAliased ( ) ? " AS " + quotize ( expression . getAlias ( ) ) : "" ; return expression . translate ( ) + ... | Translates Values . Row . |
3,097 | protected Union rowsToUnion ( final List < Expression > rows ) { List < Expression > rowsWithSelect = new ArrayList < > ( rows ) ; while ( rowsWithSelect . size ( ) > 2 ) { final List < Expression > newRowsWithSelect = new ArrayList < > ( ) ; for ( int i = 1 ; i < rowsWithSelect . size ( ) ; i += 2 ) { final Expression... | Transform values rows into a union . |
3,098 | public Query select ( final Expression ... selectColumns ) { if ( selectColumns == null ) { return this ; } return select ( Arrays . asList ( selectColumns ) ) ; } | Adds the SELECT columns . |
3,099 | private Expression getParsedOrderByColumn ( final Expression column ) { if ( column instanceof Name ) { final Name columnName = ( Name ) column ; final String environment = columnName . getEnvironment ( ) ; if ( environment != null && ! environment . isEmpty ( ) ) { final Expression parsedColumn = column ( columnName .... | Helper method which removes the environment parameter from a column when it is used inside an order by statement and in a paginated query . This is needed in order to avoid The multi - part identifier could not be bound error which only happens in SQL Server . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.